-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-24348][SQL] "element_at" error fix #21395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
cc @ueshin |
|
Good catch! |
|
ok to test. |
|
Yep, just have fixed that one as well :) |
| ) | ||
|
|
||
| intercept[AnalysisException] { | ||
| Seq(("a string element", 1)).toDF().selectExpr("element_at(_1, _2)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the error message, too.
|
Test build #90974 has finished for PR 21395 at commit
|
gatorsmile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks, Merged to master!
| left.dataType match { | ||
| case _: ArrayType => IntegerType | ||
| case _: MapType => left.dataType.asInstanceOf[MapType].keyType | ||
| case _ => AnyDataType // no match for a wrong 'left' expression type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, normally, we prefer to
override def inputTypes: Seq[AbstractDataType] = {
val rightInputType = left.dataType match {
case _: ArrayType => IntegerType
case _: MapType => left.dataType.asInstanceOf[MapType].keyType
case _ => AnyDataType // no match for a wrong 'left' expression type
}
Seq(TypeCollection(ArrayType, MapType), rightInputType)
}
|
Test build #90986 has finished for PR 21395 at commit
|
What changes were proposed in this pull request?
Fixes a
scala.MatchErrorin theelement_atoperation - SPARK-24348When calling
element_atwith a wrong first operand type anAnalysisExceptionshould be thrown instead ofscala.MatchErrorExample:
results in:
How was this patch tested?
unit tests