HyukjinKwon commented on code in PR #37637:
URL: https://github.com/apache/spark/pull/37637#discussion_r956539104
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionExpressionsSuite.scala:
##########
@@ -1535,6 +1535,24 @@ class CollectionExpressionsSuite extends SparkFunSuite
with ExpressionEvalHelper
}
checkEvaluation(ElementAt(mb0, Literal(Array[Byte](2, 1), BinaryType)),
"2")
checkEvaluation(ElementAt(mb0, Literal(Array[Byte](3, 4))), null)
+
+ // test defaultValueOutOfBound
+ val delimiter = Literal.create(".", StringType)
+ val str = StringSplitSQL(Literal.create("11.12.13", StringType), delimiter)
+ val outOfBoundValue = Some(Literal.create("", StringType))
+
+ checkEvaluation(ElementAt(str, Literal(3), outOfBoundValue),
UTF8String.fromString("13"))
+ checkEvaluation(ElementAt(str, Literal(1), outOfBoundValue),
UTF8String.fromString("11"))
+ checkEvaluation(ElementAt(str, Literal(10), outOfBoundValue),
UTF8String.fromString(""))
+ checkEvaluation(ElementAt(str, Literal(-10), outOfBoundValue),
UTF8String.fromString(""))
+
+ checkEvaluation(ElementAt(StringSplitSQL(Literal.create(null, StringType),
delimiter),
Review Comment:
This fails with ANSI mode on:
```
[info] - elementAt *** FAILED *** (309 milliseconds)
[info] Exception evaluating element_at(stringsplitsql(11.12.13, .), 10,
Some(), true) (ExpressionEvalHelper.scala:205)
[info] org.scalatest.exceptions.TestFailedException:
[info] at
org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472)
[info] at
org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471)
[info] at
org.scalatest.funsuite.AnyFunSuite.newAssertionFailedException(AnyFunSuite.scala:1563)
[info] at org.scalatest.Assertions.fail(Assertions.scala:949)
[info] at org.scalatest.Assertions.fail$(Assertions.scala:945)
[info] at org.scalatest.funsuite.AnyFunSuite.fail(AnyFunSuite.scala:1563)
[info] at
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper.checkEvaluationWithoutCodegen(ExpressionEvalHelper.scala:205)
[info] at
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper.checkEvaluationWithoutCodegen$(ExpressionEvalHelper.scala:199)
[info] at
org.apache.spark.sql.catalyst.expressions.CollectionExpressionsSuite.checkEvaluationWithoutCodegen(CollectionExpressionsSuite.scala:39)
[info] at
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper.checkEvaluation(ExpressionEvalHelper.scala:87)
[info] at
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper.checkEvaluation$(ExpressionEvalHelper.scala:82)
[info] at
org.apache.spark.sql.catalyst.expressions.CollectionExpressionsSuite.checkEvaluation(CollectionExpressionsSuite.scala:39)
[info] at
org.apache.spark.sql.catalyst.expressions.CollectionExpressionsSuite.$anonfun$new$333(CollectionExpressionsSuite.scala:1546)
```
https://github.com/apache/spark/runs/8046961366?check_suite_focus=true
--
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]