From 88afe190c2078db49d0403ab89061ebb537e5683 Mon Sep 17 00:00:00 2001 From: "Robert (Bobby) Evans" Date: Fri, 19 Nov 2021 13:25:01 -0600 Subject: [PATCH] Enable config to check for casting decimals to strings (#4163) Signed-off-by: Robert (Bobby) Evans --- .../scala/com/nvidia/spark/rapids/GpuCast.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala b/sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala index 3d9c30f9c26..1dc6b537559 100644 --- a/sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala +++ b/sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala @@ -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 " +