maropu commented on a change in pull request #30297:
URL: https://github.com/apache/spark/pull/30297#discussion_r520312599
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ComplexTypeSuite.scala
##########
@@ -62,6 +62,24 @@ class ComplexTypeSuite extends SparkFunSuite with
ExpressionEvalHelper {
checkEvaluation(GetArrayItem(nestedArray, Literal(0)), Seq(1))
}
+ test("SPARK-33391: GetArrayItem ArrayIndexOutOfBoundsException") {
+ Seq(true, false).foreach { ansiEnabled =>
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiEnabled.toString) {
+ val typeA = ArrayType(StringType)
+ val array = Literal.create(Seq("a", "b"), typeA)
+
+ if (ansiEnabled) {
+ val ex = intercept[Exception] {
+ checkEvaluation(GetArrayItem(array, Literal(5)), null)
Review comment:
Could we use `checkExceptionInExpression` instead?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]