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 2021/12/03 19:10:30 UTC

[GitHub] [spark] allisonwang-db commented on a change in pull request #34796: [SPARK-37533][SQL] New SQL function: try_element_at

allisonwang-db commented on a change in pull request #34796:
URL: https://github.com/apache/spark/pull/34796#discussion_r762175325



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
##########
@@ -348,11 +348,13 @@ case class Elt(
       }.mkString)
 
     val indexOutOfBoundBranch = if (failOnError) {
+      // scalastyle:off line.size.limit
       s"""
          |if (!$indexMatched) {
-         |  throw QueryExecutionErrors.invalidArrayIndexError(${index.value}, ${inputExprs.length});
+         |  throw QueryExecutionErrors.invalidStringIndexError(${index.value}, ${inputExprs.length});

Review comment:
       `invalidInputIndexError`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -82,6 +82,9 @@
     "message" : [ "The fraction of sec must be zero. Valid range is [0, 60]. If necessary set %s to false to bypass this error. " ],
     "sqlState" : "22023"
   },
+  "INVALID_INPUT_INDEX" : {

Review comment:
       Do we need to add a new error? The error message here seems a little inconsistent between map and array access using `[]` operator:
   ```
   SELECT array(1,2,3)[3];   // Do not hint `try_element_at`
   SELECT map('a', 1, 'b', 2)['c'];  // Hint `try_element_at`
   ```




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