Skip to content

Commit 3c154ca

Browse files
authored
fix: correct invalid Option.contains assertion in cast test (#3851)
1 parent f210412 commit 3c154ca

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

spark/src/test/scala/org/apache/comet/CometCastSuite.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import scala.util.Random
2727
import org.apache.hadoop.fs.Path
2828
import org.apache.spark.sql.{CometTestBase, DataFrame, Row, SaveMode}
2929
import org.apache.spark.sql.catalyst.expressions.Cast
30+
import org.apache.spark.sql.catalyst.parser.ParseException
3031
import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
3132
import org.apache.spark.sql.functions.col
3233
import org.apache.spark.sql.internal.SQLConf
@@ -1287,8 +1288,13 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
12871288
// cast to negative scale
12881289
checkSparkAnswerMaybeThrows(
12891290
spark.sql("select a, cast(a as DECIMAL(10,-4)) from t order by a")) match {
1291+
case (Some(expected: ParseException), Some(actual: ParseException)) =>
1292+
assert(
1293+
expected.getMessage.contains("PARSE_SYNTAX_ERROR") && actual.getMessage.contains(
1294+
"PARSE_SYNTAX_ERROR"))
12901295
case (expected, actual) =>
1291-
assert(expected.contains("PARSE_SYNTAX_ERROR") === actual.contains("PARSE_SYNTAX_ERROR"))
1296+
fail(
1297+
s"Expected Spark and Comet throw ParseException, but got Spark=$expected and Comet=$actual")
12921298
}
12931299
}
12941300

0 commit comments

Comments
 (0)