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 <pbk1...@gmail.com>
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 <pbk1...@gmail.com>
    Signed-off-by: Max Gekk <max.g...@gmail.com>
---
 .../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: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to