Skip to content

Commit

Permalink
Enable config to check for casting decimals to strings (#4163)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert (Bobby) Evans <bobby@apache.org>
  • Loading branch information
revans2 authored Nov 19, 2021
1 parent 45898e0 commit 88afe19
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ final class CastExprMeta[INPUT <: CastBase](
case (FloatType | DoubleType, ByteType | ShortType | IntegerType | LongType) if
doFloatToIntCheck && !conf.isCastFloatToIntegralTypesEnabled =>
willNotWorkOnGpu(buildTagMessage(RapidsConf.ENABLE_CAST_FLOAT_TO_INTEGRAL_TYPES))
case (dt: DecimalType, _: StringType) if dt.precision > DType.DECIMAL64_MAX_PRECISION =>
willNotWorkOnGpu(s"decimal to string with a " +
s"precision > ${DType.DECIMAL64_MAX_PRECISION} is not supported yet")
case (dt: DecimalType, _: StringType) =>
if (!conf.isCastDecimalToStringEnabled) {
willNotWorkOnGpu("the GPU does not produce the exact same string as Spark produces, " +
s"set ${RapidsConf.ENABLE_CAST_DECIMAL_TO_STRING} to true if semantically " +
s"equivalent decimal strings are sufficient for your application.")
}
if (dt.precision > DType.DECIMAL64_MAX_PRECISION) {
willNotWorkOnGpu(s"decimal to string with a " +
s"precision > ${DType.DECIMAL64_MAX_PRECISION} is not supported yet")
}
case ( _: DecimalType, _: FloatType | _: DoubleType) if !conf.isCastDecimalToFloatEnabled =>
willNotWorkOnGpu("the GPU will use a different strategy from Java's BigDecimal " +
"to convert decimal data types to floating point and this can produce results that " +
Expand Down

0 comments on commit 88afe19

Please sign in to comment.