This is an automated email from the ASF dual-hosted git repository. maxgekk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 65d6ee5e791 [SPARK-38722][SQL][TESTS] Test the error class: CAST_CAUSES_OVERFLOW 65d6ee5e791 is described below commit 65d6ee5e791b9220de015324ffc67db11380378e Author: panbingkun <pbk1...@gmail.com> AuthorDate: Fri Apr 15 09:30:52 2022 +0300 [SPARK-38722][SQL][TESTS] Test the error class: CAST_CAUSES_OVERFLOW ### What changes were proposed in this pull request? This pr aims to Add one test for the error class CAST_CAUSES_OVERFLOW to QueryExecutionErrorsSuite, it's a followup of SPARK-37935. ### Why are the changes needed? Add one test for the error class CAST_CAUSES_OVERFLOW to QueryExecutionErrorsSuite ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Manual test: ``` ./build/sbt "sql/testOnly *QueryExecutionErrorsSuite*" ``` All tests passed. Closes #36199 from panbingkun/SPARK-38722. Authored-by: panbingkun <pbk1...@gmail.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- .../apache/spark/sql/errors/QueryExecutionErrorsSuite.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala index 77eb6b28d54..aa891b70ac0 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala @@ -357,4 +357,17 @@ class QueryExecutionErrorsSuite extends QueryTest } } } + + test("CAST_CAUSES_OVERFLOW: from timestamp to int") { + withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") { + val e = intercept[SparkArithmeticException] { + sql("select CAST(TIMESTAMP '9999-12-31T12:13:14.56789Z' AS INT)").collect() + } + assert(e.getErrorClass === "CAST_CAUSES_OVERFLOW") + assert(e.getSqlState === "22005") + assert(e.getMessage === "Casting 253402258394567890L to int causes overflow. " + + "To return NULL instead, use 'try_cast'. " + + "If necessary set spark.sql.ansi.enabled to false to bypass this error.") + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org