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 7246d25cc9e [SPARK-38750][SQL][TESTS] Test the error class:
SECOND_FUNCTION_ARGUMENT_NOT_INTEGER
7246d25cc9e is described below
commit 7246d25cc9ec36dafe6b7df16c78b704c5934d84
Author: panbingkun <[email protected]>
AuthorDate: Sat Apr 16 12:04:31 2022 +0300
[SPARK-38750][SQL][TESTS] Test the error class:
SECOND_FUNCTION_ARGUMENT_NOT_INTEGER
## What changes were proposed in this pull request?
This PR aims to add a test for the error class
SECOND_FUNCTION_ARGUMENT_NOT_INTEGER to `QueryCompilationErrorsSuite`.
### Why are the changes needed?
The changes improve test coverage, and document expected error messages in
tests.
### Does this PR introduce any user-facing change?
No
### How was this patch tested?
By running new test:
```
$ build/sbt "sql/testOnly *QueryCompilationErrorsSuite*"
```
Closes #36209 from panbingkun/SPARK-38750.
Lead-authored-by: panbingkun <[email protected]>
Co-authored-by: Maxim Gekk <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
.../apache/spark/sql/errors/QueryCompilationErrorsSuite.scala | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
index de671df74c8..34e3f305530 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
@@ -310,6 +310,17 @@ class QueryCompilationErrorsSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("SECOND_FUNCTION_ARGUMENT_NOT_INTEGER: " +
+ "the second argument of 'date_add' function needs to be an integer") {
+ val e = intercept[AnalysisException] {
+ sql("select date_add('1982-08-15', 'x')").collect()
+ }
+ assert(e.getErrorClass === "SECOND_FUNCTION_ARGUMENT_NOT_INTEGER")
+ assert(e.getSqlState === "22023")
+ assert(e.getMessage ===
+ "The second argument of 'date_add' function needs to be an integer.")
+ }
}
class MyCastToString extends SparkUserDefinedFunction(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]