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 a9b2d76801a [SPARK-38724][SQL][TESTS] Test the error class:
DIVIDE_BY_ZERO
a9b2d76801a is described below
commit a9b2d76801ac18711fdc8184f91fe64dfe81bbd7
Author: panbingkun <[email protected]>
AuthorDate: Fri Apr 15 21:33:46 2022 +0300
[SPARK-38724][SQL][TESTS] Test the error class: DIVIDE_BY_ZERO
## What changes were proposed in this pull request?
This pr aims to add one test for the error class DIVIDE_BY_ZERO to
QueryExecutionErrorsSuite, it's a followup of
[SPARK-37935](https://issues.apache.org/jira/browse/SPARK-37935).
### Why are the changes needed?
Add one test for the error class DIVIDE_BY_ZERO 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 #36193 from panbingkun/SPARK-38724.
Lead-authored-by: panbingkun <[email protected]>
Co-authored-by: Maxim Gekk <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
.../spark/sql/errors/QueryExecutionErrorsSuite.scala | 18 ++++++++++++++++++
1 file changed, 18 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 aa891b70ac0..d3c242266be 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
@@ -370,4 +370,22 @@ class QueryExecutionErrorsSuite extends QueryTest
"If necessary set spark.sql.ansi.enabled to false to bypass this
error.")
}
}
+
+ test("DIVIDE_BY_ZERO: can't divide an integer by zero") {
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+ val e = intercept[SparkArithmeticException] {
+ sql("select 6/0").collect()
+ }
+ assert(e.getErrorClass === "DIVIDE_BY_ZERO")
+ assert(e.getSqlState === "22012")
+ assert(e.getMessage ===
+ "divide by zero. To return NULL instead, use 'try_divide'. If
necessary set " +
+ "spark.sql.ansi.enabled to false (except for ANSI interval type) to
bypass this error." +
+ """
+ |== SQL(line 1, position 7) ==
+ |select 6/0
+ | ^^^
+ |""".stripMargin)
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]