-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-34515][SQL] Fix NPE if InSet contains null value during getPartitionsByFilter #31632
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 all commits
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 | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -769,7 +769,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 { | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| case InSet(child, values) if useAdvanced && values.size > inSetThreshold => | ||||||||||||||||||||||||||||||||||||||||
| val dataType = child.dataType | ||||||||||||||||||||||||||||||||||||||||
| val sortedValues = values.toSeq.sorted(TypeUtils.getInterpretedOrdering(dataType)) | ||||||||||||||||||||||||||||||||||||||||
| // Skip null here is safe, more details could see at ExtractableLiterals. | ||||||||||||||||||||||||||||||||||||||||
| val sortedValues = values.filter(_ != null).toSeq | ||||||||||||||||||||||||||||||||||||||||
| .sorted(TypeUtils.getInterpretedOrdering(dataType)) | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+773
to
+774
Member
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. Will this change the result of
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. same question here. The null sematic of IN is pretty tricky.
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. It's safe, since spark/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala Lines 666 to 684 in 714ff73
|
||||||||||||||||||||||||||||||||||||||||
| convert(And(GreaterThanOrEqual(child, Literal(sortedValues.head, dataType)), | ||||||||||||||||||||||||||||||||||||||||
| LessThanOrEqual(child, Literal(sortedValues.last, dataType)))) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
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.
Shall we add a similar comment for why this is safe, similar to
IN- #21832 ?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.
looks better