You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2022/04/15 06:31:11 UTC
[spark] branch master updated: [SPARK-38722][SQL][TESTS] Test the error class: CAST_CAUSES_OVERFLOW
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 <pb...@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 <pb...@gmail.com>
Signed-off-by: Max Gekk <ma...@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-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org