Skip to content

Commit d6b9f83

Browse files
viiryaIsaac
andcommitted
Check the error parameters in every evaluation mode
Co-authored-by: Isaac <[email protected]>
1 parent 4a81cfd commit d6b9f83

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

‎sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastWithAnsiOnSuite.scala‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -493,19 +493,25 @@ class CastWithAnsiOnSuite extends CastSuiteBase with QueryErrorsBase {
493493
// The value is shown in plain notation unless its scale is hugely negative.
494494
Seq("1e2147483647" -> "1E+2147483647", "1e40" -> ("1" + "0" * 40)).foreach {
495495
case (str, value) =>
496+
def expr: Expression = cast(str, DecimalType(10, 2))
496497
if (!isTryCast) {
497-
checkError(
498-
exception = intercept[SparkArithmeticException](
499-
cast(str, DecimalType(10, 2)).eval()),
500-
condition = "NUMERIC_VALUE_OUT_OF_RANGE.WITH_SUGGESTION",
501-
parameters = Map(
502-
"value" -> value,
503-
"precision" -> "10",
504-
"scale" -> "2",
505-
"config" -> """"spark.sql.ansi.enabled""""),
506-
queryContext = Array(ExpectedContext(fragment = "", start = -1, stop = -1)))
498+
// Interpreted, and both codegen paths, which report the error from `CastUtils`.
499+
Seq[Expression => Any](
500+
evaluateWithoutCodegen(_),
501+
evaluateWithMutableProjection(_),
502+
evaluateWithUnsafeProjection(_)).foreach { eval =>
503+
checkError(
504+
exception = intercept[SparkArithmeticException](eval(expr)),
505+
condition = "NUMERIC_VALUE_OUT_OF_RANGE.WITH_SUGGESTION",
506+
parameters = Map(
507+
"value" -> value,
508+
"precision" -> "10",
509+
"scale" -> "2",
510+
"config" -> """"spark.sql.ansi.enabled""""),
511+
queryContext = Array(ExpectedContext(fragment = "", start = -1, stop = -1)))
512+
}
507513
} else {
508-
checkEvaluation(cast(str, DecimalType(10, 2)), null)
514+
checkEvaluation(expr, null)
509515
}
510516
}
511517
}

0 commit comments

Comments
 (0)