From 6d042addd898b6760e4c8a014cb2cbcec4bcf189 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sun, 21 Apr 2024 09:14:28 -0600 Subject: [PATCH] Fix test failures --- .../scala/org/apache/comet/CometCastSuite.scala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala index f04f94d56..1eba86d56 100644 --- a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala @@ -152,7 +152,18 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper { // We have to workaround https://github.com/apache/datafusion-comet/issues/293 here by // removing the "Execution error: " error message prefix that is added by DataFusion - assert(expected.getMessage == actual.getMessage.substring("Execution error: ".length)) + val actualCometMessage = actual.getMessage + .substring("Execution error: ".length) + + val cometMessage = if (CometSparkSessionExtensions.isSpark34Plus) { + actualCometMessage + } else { + // Comet follows Spark 3.4 behavior and starts the string with [CAST_INVALID_INPUT] but + // this does not appear in Spark 3.2 or 3.3, so we strip it off before comparing + actualCometMessage.replace("[CAST_INVALID_INPUT]", "") + } + + assert(expected.getMessage == cometMessage) // try_cast() should always return null for invalid inputs val df2 = spark.sql(s"select try_cast(a as ${toType.sql}) from t")