maropu commented on a change in pull request #30297:
URL: https://github.com/apache/spark/pull/30297#discussion_r520312458
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala
##########
@@ -3621,6 +3621,25 @@ class DataFrameFunctionsSuite extends QueryTest with
SharedSparkSession {
df.select(map(map_entries($"m"), lit(1))),
Row(Map(Seq(Row(1, "a")) -> 1)))
}
+
+ test("SPARK-33391: element_at ArrayIndexOutOfBoundsException") {
+ Seq(true, false).foreach { ansiEnabled =>
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiEnabled.toString) {
+ val df = sql("select element_at(array(1, 2, 3), 5)")
+ if (ansiEnabled) {
+ val ex = intercept[Exception] {
+ df.collect()
+ }
+ assert(ex.getMessage.contains("Invalid index: 5"))
+ } else {
+ checkAnswer(
Review comment:
Could you add fine-grained tests for `element_at` and `elt ` via
`checkExceptionInExpression`?
----------------------------------------------------------------
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]