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 581c801e02f [SPARK-38718][SQL][TESTS] Test the error class: 
AMBIGUOUS_FIELD_NAME
581c801e02f is described below

commit 581c801e02f97712545399f37ce6e7acac7af5b5
Author: panbingkun <pbk1...@gmail.com>
AuthorDate: Thu Apr 28 23:29:17 2022 +0300

    [SPARK-38718][SQL][TESTS] Test the error class: AMBIGUOUS_FIELD_NAME
    
    ## What changes were proposed in this pull request?
    This PR aims to add a test for the error class AMBIGUOUS_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 #36395 from panbingkun/SPARK-38718.
    
    Authored-by: panbingkun <pbk1...@gmail.com>
    Signed-off-by: Max Gekk <max.g...@gmail.com>
---
 .../spark/sql/errors/QueryCompilationErrorsSuite.scala    | 15 +++++++++++++++
 1 file changed, 15 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 2d1e6f94925..ec8edd2acd6 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
@@ -476,6 +476,21 @@ class QueryCompilationErrorsSuite
       checkAnswer(sql("SELECT __auto_generated_subquery_name.i from (SELECT i 
FROM v)"), Row(1))
     }
   }
+
+  test("AMBIGUOUS_FIELD_NAME: alter column matching multi fields in the 
struct") {
+    withTable("t") {
+      withSQLConf(SQLConf.CASE_SENSITIVE.key -> "true") {
+        sql("CREATE TABLE t(c struct<X:String, x:String>) USING parquet")
+      }
+
+      checkErrorClass(
+        exception = intercept[AnalysisException] {
+          sql("ALTER TABLE t CHANGE COLUMN c.X COMMENT 'new comment'")
+        },
+        errorClass = "AMBIGUOUS_FIELD_NAME",
+        msg = "Field name c.X is ambiguous and has 2 matching fields in the 
struct.; line 1 pos 0")
+    }
+  }
 }
 
 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