Skip to content

Commit

Permalink
Fix spark330 build due to mapKeyNotExistError changed
Browse files Browse the repository at this point in the history
Signed-off-by: Chong Gao <res_life@163.com>
  • Loading branch information
Chong Gao committed Apr 28, 2022
1 parent 447223e commit 98a9e29
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.nvidia.spark.rapids.shims

import org.apache.spark.sql.catalyst.trees.Origin
import org.apache.spark.sql.types.DataType

object RapidsErrorUtils {
def invalidArrayIndexError(index: Int, numElements: Int,
Expand All @@ -27,6 +28,7 @@ object RapidsErrorUtils {

def mapKeyNotExistError(
key: String,
keyType: DataType,
origin: Origin): NoSuchElementException = {
// Follow the Spark string format before 3.3.0
new NoSuchElementException(s"Key $key does not exist.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.nvidia.spark.rapids.shims

import org.apache.spark.sql.catalyst.trees.Origin
import org.apache.spark.sql.types.DataType

object RapidsErrorUtils {
def invalidArrayIndexError(index: Int, numElements: Int,
Expand All @@ -27,6 +28,7 @@ object RapidsErrorUtils {

def mapKeyNotExistError(
key: String,
keyType: DataType,
origin: Origin): NoSuchElementException = {
// Follow the Spark string format before 3.3.0
new NoSuchElementException(s"Key $key does not exist.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.nvidia.spark.rapids.shims

import org.apache.spark.sql.catalyst.trees.Origin
import org.apache.spark.sql.errors.QueryExecutionErrors
import org.apache.spark.sql.types.DataType

object RapidsErrorUtils {
def invalidArrayIndexError(index: Int, numElements: Int,
Expand All @@ -31,6 +32,7 @@ object RapidsErrorUtils {

def mapKeyNotExistError(
key: String,
keyType: DataType,
origin: Origin): NoSuchElementException = {
// For now, the default argument is false. The caller sets the correct value accordingly.
QueryExecutionErrors.mapKeyNotExistError(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.nvidia.spark.rapids.shims

import org.apache.spark.sql.catalyst.trees.Origin
import org.apache.spark.sql.errors.QueryExecutionErrors
import org.apache.spark.sql.types.DataType

object RapidsErrorUtils {
def invalidArrayIndexError(index: Int, numElements: Int,
Expand All @@ -31,8 +32,9 @@ object RapidsErrorUtils {

def mapKeyNotExistError(
key: String,
keyType: DataType,
origin: Origin): NoSuchElementException = {
QueryExecutionErrors.mapKeyNotExistError(key, origin.context)
QueryExecutionErrors.mapKeyNotExistError(key, keyType, origin.context)
}

def sqlArrayIndexNotStartAtOneError(): ArrayIndexOutOfBoundsException = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ case class GpuElementAt(left: Expression, right: Expression, failOnError: Boolea
array.extractListElement(idx)
}
}
case _: MapType =>
case MapType(keyType, _, _) =>
(map, keyS) => {
val key = keyS.getBase
if (failOnError) {
Expand All @@ -232,7 +232,8 @@ case class GpuElementAt(left: Expression, right: Expression, failOnError: Boolea
if (!exist.isValid || exist.getBoolean) {
map.getMapValue(key)
} else {
throw RapidsErrorUtils.mapKeyNotExistError(keyS.getValue.toString, origin)
throw RapidsErrorUtils.mapKeyNotExistError(keyS.getValue.toString, keyType,
origin)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ case class GpuGetMapValue(child: Expression, key: Expression, failOnError: Boole
withResource(lhs.getBase.getMapKeyExistence(rhs.getBase)) { keyExistenceColumn =>
withResource(keyExistenceColumn.all) { exist =>
if (exist.isValid && !exist.getBoolean) {
throw RapidsErrorUtils.mapKeyNotExistError(rhs.getValue.toString, origin)
throw RapidsErrorUtils.mapKeyNotExistError(rhs.getValue.toString, keyType, origin)
}
}
}
Expand Down

0 comments on commit 98a9e29

Please sign in to comment.