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 81786a2e960 [SPARK-38737][SQL][TESTS] Test the error classes:
INVALID_FIELD_NAME
81786a2e960 is described below
commit 81786a2e9601aaaa8ded474b353c004ac2f63fde
Author: panbingkun <[email protected]>
AuthorDate: Sun May 1 11:35:09 2022 +0300
[SPARK-38737][SQL][TESTS] Test the error classes: INVALID_FIELD_NAME
## What changes were proposed in this pull request?
This PR aims to add a test for the error class INVALID_FIELD_NAME 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 #36404 from panbingkun/SPARK-38737.
Authored-by: panbingkun <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
.../spark/sql/errors/QueryCompilationErrorsSuite.scala | 14 ++++++++++++++
1 file changed, 14 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 1115db07f21..8fffccbed40 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
@@ -513,6 +513,20 @@ class QueryCompilationErrorsSuite
msg = "Invalid pivot value 'struct(col1, dotnet, col2, Experts)': value
data type " +
"struct<col1:string,col2:string> does not match pivot column data type
int")
}
+
+ test("INVALID_FIELD_NAME: add a nested field for not struct parent") {
+ withTable("t") {
+ sql("CREATE TABLE t(c struct<x:string>, m string) USING parquet")
+
+ val e = intercept[AnalysisException] {
+ sql("ALTER TABLE t ADD COLUMNS (m.n int)")
+ }
+ checkErrorClass(
+ exception = e,
+ errorClass = "INVALID_FIELD_NAME",
+ msg = "Field name m.n is invalid: m is not a struct.; line 1 pos 27")
+ }
+ }
}
class MyCastToString extends SparkUserDefinedFunction(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]