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 2020/11/10 05:59:24 UTC

[GitHub] [spark] maropu commented on a change in pull request #30297: [SPARK-33386][SQL] Accessing array elements should failed if index is out of bound.

maropu commented on a change in pull request #30297:
URL: https://github.com/apache/spark/pull/30297#discussion_r520305448



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/StringFunctionsSuite.scala
##########
@@ -617,4 +617,23 @@ class StringFunctionsSuite extends QueryTest with SharedSparkSession {
     )
 
   }
+
+  test("SPARK-33391: elt ArrayIndexOutOfBoundsException") {
+    Seq(true, false).foreach { ansiEnabled =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiEnabled.toString) {
+        val df = sql("select elt(4, '123', '456')")
+        if (ansiEnabled) {
+          val ex = intercept[Exception] {
+            df.collect()
+          }
+          assert(ex.getMessage.contains("Invalid index: 4"))
+        } else {
+          checkAnswer(

Review comment:
       nit: could you put this in a single line?
   ```
   checkAnswer(df, Row(null))
   ```




----------------------------------------------------------------
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.

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