Skip to content

Commit

Permalink
Fix CPU fallback for Map lookup.
Browse files Browse the repository at this point in the history
Fixes NVIDIA#5180.

Map lookup is currently supported only in cases where the keys are
scalar values. In case the keys are specified as a vector (e.g.
expressions), the plugin should fall back to CPU.
NVIDIA#4944 introduced a bug in how literal signatures are specified for
multiple data types. This breaks CPU fallback.

This commit fixes the specification of literals-only `TypeSig`.
  • Loading branch information
mythrocks committed Apr 8, 2022
1 parent 68feebc commit 339f6b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ final class TypeSig private(
new TypeSig(it, maxAllowedDecimalPrecision, childTypes, lt, notes)
}

/**
* Add a literal restriction to the signature
* @param dataTypes the types that have to be literal. Will be added if they do not already exist.
* @return the new signature.
*/
def withLit(dataTypes: TypeEnum.ValueSet): TypeSig = {
val it = initialTypes ++ dataTypes
val lt = litOnlyTypes ++ dataTypes
new TypeSig(it, maxAllowedDecimalPrecision, childTypes, lt, notes)
}

/**
* All currently supported types can only be literal values.
* @return the new signature.
Expand Down Expand Up @@ -531,7 +542,7 @@ object TypeSig {
* Create a TypeSig that only supports literals of certain given types.
*/
def lit(dataTypes: TypeEnum.ValueSet): TypeSig =
new TypeSig(dataTypes)
TypeSig.none.withLit(dataTypes)

/**
* Create a TypeSig that supports only literals of common primitive CUDF types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ case class GpuGetMapValue(child: Expression, key: Expression, failOnError: Boole
}

override def doColumnar(lhs: GpuScalar, rhs: GpuColumnVector): ColumnVector =
throw new IllegalStateException("This is not supported yet")
throw new IllegalStateException("Map lookup keys must be scalar values")

override def doColumnar(lhs: GpuColumnVector, rhs: GpuColumnVector): ColumnVector =
throw new IllegalStateException("This is not supported yet")
throw new IllegalStateException("Map lookup keys must be scalar values")

override def left: Expression = child

Expand Down

0 comments on commit 339f6b7

Please sign in to comment.