Skip to content

Commit ec2e4a6

Browse files
committed
SPARK-24348 "element_at" error fix
1 parent fc743f7 commit ec2e4a6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ case class ElementAt(left: Expression, right: Expression) extends GetMapValueUti
14691469
left.dataType match {
14701470
case _: ArrayType => IntegerType
14711471
case _: MapType => left.dataType.asInstanceOf[MapType].keyType
1472+
case _ => AnyDataType // no match for a wrong 'left' expression type
14721473
}
14731474
)
14741475
}

sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSQLContext {
756756
df.selectExpr("element_at(a, -1)"),
757757
Seq(Row("3"), Row(""), Row(null))
758758
)
759+
760+
intercept[AnalysisException] {
761+
Seq(("a string element", 1)).toDF().selectExpr("element_at(_1, _2)")
762+
}
759763
}
760764

761765
test("concat function - arrays") {

0 commit comments

Comments
 (0)