You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/17 03:43:28 UTC

[GitHub] [spark] panbingkun opened a new pull request, #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

panbingkun opened a new pull request, #36232:
URL: https://github.com/apache/spark/pull/36232

   ## What changes were proposed in this pull request?
   This PR aims to add a test for the error class MAP_KEY_DOES_NOT_EXIST* to `QueryExecutionErrorsSuite`.
   
   ### 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 *QueryExecutionErrorsSuite*"
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on a diff in pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #36232:
URL: https://github.com/apache/spark/pull/36232#discussion_r851721680


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -400,4 +400,37 @@ class QueryExecutionErrorsSuite extends QueryTest
         "If necessary set spark.sql.ansi.enabled to false to bypass this error. ")
     }
   }
+
+  test("MAP_KEY_DOES_NOT_EXIST_IN_ELEMENT_AT: key does not exist") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      val e1 = intercept[SparkNoSuchElementException] {
+        sql("select element_at(map(1, 'a', 2, 'b'), 3)").collect()
+      }
+      assert(e1.getErrorClass === "MAP_KEY_DOES_NOT_EXIST_IN_ELEMENT_AT")
+      assert(e1.getMessage ===
+        "Key 3 does not exist. To return NULL instead, use 'try_element_at'. " +
+          "If necessary set spark.sql.ansi.enabled to false to bypass this error." +
+          """
+            |== SQL(line 1, position 7) ==
+            |select element_at(map(1, 'a', 2, 'b'), 3)
+            |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+            |""".stripMargin)

Review Comment:
   Not need to indent additionally.



##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -400,4 +400,37 @@ class QueryExecutionErrorsSuite extends QueryTest
         "If necessary set spark.sql.ansi.enabled to false to bypass this error. ")
     }
   }
+
+  test("MAP_KEY_DOES_NOT_EXIST_IN_ELEMENT_AT: key does not exist") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      val e1 = intercept[SparkNoSuchElementException] {
+        sql("select element_at(map(1, 'a', 2, 'b'), 3)").collect()
+      }
+      assert(e1.getErrorClass === "MAP_KEY_DOES_NOT_EXIST_IN_ELEMENT_AT")
+      assert(e1.getMessage ===
+        "Key 3 does not exist. To return NULL instead, use 'try_element_at'. " +
+          "If necessary set spark.sql.ansi.enabled to false to bypass this error." +
+          """
+            |== SQL(line 1, position 7) ==
+            |select element_at(map(1, 'a', 2, 'b'), 3)
+            |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+            |""".stripMargin)
+    }
+  }
+
+  test("MAP_KEY_DOES_NOT_EXIST: key does not exist") {

Review Comment:
   Where is the checks of error class and error message?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on PR #36232:
URL: https://github.com/apache/spark/pull/36232#issuecomment-1110994302

   @panbingkun ping


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] panbingkun commented on pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

Posted by GitBox <gi...@apache.org>.
panbingkun commented on PR #36232:
URL: https://github.com/apache/spark/pull/36232#issuecomment-1111776079

   > @panbingkun ping
   
   Done @MaxGekk 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk closed pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST

Posted by GitBox <gi...@apache.org>.
MaxGekk closed pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST
URL: https://github.com/apache/spark/pull/36232


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on PR #36232:
URL: https://github.com/apache/spark/pull/36232#issuecomment-1106041088

   @panbingkun Could you resolve conflicts, here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #36232: [SPARK-38741][SQL][TESTS] Test the error class: MAP_KEY_DOES_NOT_EXIST*

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #36232:
URL: https://github.com/apache/spark/pull/36232#issuecomment-1100799235

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org