Skip to content

Commit 646d96e

Browse files
committed
[SPARK-52515][SQL][TESTS][FOLLOW-UP] Explicitly enable ANSI for overflow error case
### What changes were proposed in this pull request? This PR is a followup of #51236 that explicily enables ANSI for overflow error test case ### Why are the changes needed? The non-ANSI build is broken https://github.com/apache/spark/actions/runs/15987607479 ### Does this PR introduce _any_ user-facing change? No, test-only. ### How was this patch tested? Manually. ### Was this patch authored or co-authored using generative AI tooling? No Closes #51328 from HyukjinKwon/SPARK-52515-followup. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 8b6eeca commit 646d96e

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,19 +2760,21 @@ class DataFrameAggregateSuite extends QueryTest
27602760
}
27612761

27622762
test("SPARK-52515: invalid k value > Int.MaxValue") {
2763-
val k: Long = Int.MaxValue + 1L
2764-
checkError(
2765-
exception = intercept[SparkArithmeticException] {
2766-
sql(s"SELECT approx_top_k(expr, $k) FROM VALUES (0), (1), (2) AS tab(expr);").collect()
2767-
},
2768-
condition = "CAST_OVERFLOW",
2769-
parameters = Map(
2770-
"value" -> (k.toString + "L"),
2771-
"sourceType" -> "\"BIGINT\"",
2772-
"targetType" -> "\"INT\"",
2773-
"ansiConfig" -> "\"spark.sql.ansi.enabled\""
2763+
withSQLConf("spark.sql.ansi.enabled" -> true.toString) {
2764+
val k: Long = Int.MaxValue + 1L
2765+
checkError(
2766+
exception = intercept[SparkArithmeticException] {
2767+
sql(s"SELECT approx_top_k(expr, $k) FROM VALUES (0), (1), (2) AS tab(expr);").collect()
2768+
},
2769+
condition = "CAST_OVERFLOW",
2770+
parameters = Map(
2771+
"value" -> (k.toString + "L"),
2772+
"sourceType" -> "\"BIGINT\"",
2773+
"targetType" -> "\"INT\"",
2774+
"ansiConfig" -> "\"spark.sql.ansi.enabled\""
2775+
)
27742776
)
2775-
)
2777+
}
27762778
}
27772779

27782780
test("SPARK-52515: invalid k value null") {

0 commit comments

Comments
 (0)