amaliujia commented on a change in pull request #35352:
URL: https://github.com/apache/spark/pull/35352#discussion_r829353129
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -2095,7 +2095,9 @@ case class ArrayPosition(left: Expression, right:
Expression)
case class ElementAt(
left: Expression,
right: Expression,
- failOnError: Boolean = SQLConf.get.ansiEnabled)
+ failOnError: Boolean = SQLConf.get.ansiEnabled,
+ // The value to return if index is out of bound
+ defaultValueOutOfBound: Any = null)
Review comment:
Is there an example of how to create a Literal("") for Expression type
of `defaultValueOutOfBound`?
I tried `Literal("")`, etc. It always gives me this error:
```
requirement failed: Literal must have a corresponding value to string, but
class String found.
java.lang.IllegalArgumentException: requirement failed: Literal must have a
corresponding value to string, but class String found.
at scala.Predef$.require(Predef.scala:281)
at
org.apache.spark.sql.catalyst.expressions.Literal$.validateLiteralValue(literals.scala:242)
at
org.apache.spark.sql.catalyst.expressions.Literal.<init>(literals.scala:331)
at
org.apache.spark.sql.catalyst.expressions.SplitPart.replacement$lzycompute(stringExpressions.scala:3017)
at
org.apache.spark.sql.catalyst.expressions.SplitPart.replacement(stringExpressions.scala:3016)
at
org.apache.spark.sql.catalyst.expressions.RuntimeReplaceable.dataType(Expression.scala:361)
at
org.apache.spark.sql.catalyst.expressions.RuntimeReplaceable.dataType$(Expression.scala:361)
at
org.apache.spark.sql.catalyst.expressions.SplitPart.dataType(stringExpressions.scala:3011)
at
org.apache.spark.sql.catalyst.expressions.Alias.toAttribute(namedExpressions.scala:197)
at
org.apache.spark.sql.catalyst.plans.logical.Project.$anonfun$output$1(basicLogicalOperators.scala:70)
at scala.collection.immutable.List.map(List.scala:293)
```
--
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]