-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-13056][SQL] map column would throw NPE if value is null #10964
Changes from 6 commits
5b2d942
2244999
bf429ca
21f29a5
898cf20
d77013f
5b83626
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2046,6 +2046,15 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
) | ||
} | ||
|
||
test("SPARK-13056: Null in map value causes NPE") { | ||
val df = Seq(1 -> Map("abc" -> "somestring", "cba" -> null)).toDF("key", "value") | ||
withTempTable("maptest") { | ||
df.registerTempTable("maptest") | ||
checkAnswer(sql("SELECT value['abc'] FROM maptest where key = 1"), Row("somestring")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I explained before, the problem is local optimization: #10964 (comment) , so adding a filter here do fixes the problem, by breaking the local optimization, and we should add comments to say it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right |
||
checkAnswer(sql("SELECT value['cba'] FROM maptest where key = 1"), Row(null)) | ||
} | ||
} | ||
|
||
test("hash function") { | ||
val df = Seq(1 -> "a", 2 -> "b").toDF("i", "j") | ||
withTempTable("tbl") { | ||
|
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.
Just realized it is ok to let it return null here, without the condition above.
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.
yea, it's ok, but having it makes the interpreted version and codegen version more consistent, which is good.