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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to