-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-13056][SQL] map column would throw NPE if value is null #10964
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
Changes from 4 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 |
|---|---|---|
|
|
@@ -2056,4 +2056,11 @@ 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") | ||
| df.registerTempTable("maptest") | ||
|
Contributor
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. use |
||
| checkAnswer(sql("SELECT value['abc'] FROM maptest"), Row("somestring")) | ||
| checkAnswer(sql("SELECT value['cba'] FROM maptest"), Row(null)) | ||
|
Contributor
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. Have you verified if this throws NPE without this fix ? The test runs fine over trunk:
Contributor
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. I think we need to use
Contributor
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. You need to modify the test case:
Contributor
Author
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. @tejasapatil OK, actually I used a udf to generate the map and got your exception, later I changed to this following the guide from @cloud-fan but didn't verify it myself. I'll modify the test case here, Thanks! |
||
| } | ||
| } | ||
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.