-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-33845][SQL] Remove unnecessary if when trueValue and falseValue are foldable boolean types #30849
Conversation
Test build #133045 has finished for PR 30849 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status failure |
Kubernetes integration test starting |
Test build #133051 has finished for PR 30849 at commit
|
Test build #133052 has finished for PR 30849 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
Outdated
Show resolved
Hide resolved
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 reasonable to me.
Kubernetes integration test starting |
Kubernetes integration test status success |
@@ -199,4 +199,20 @@ class SimplifyConditionalSuite extends PlanTest with ExpressionEvalHelper with P | |||
If(Factorial(5) > 100L, b, nullLiteral).eval(EmptyRow)) | |||
} | |||
} | |||
|
|||
test("remove unnecessary if when the outputs are boolean 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.
I would add JIRA prefix, though.
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.
+1, LGTM (except @HyukjinKwon 's the JIRA prefix 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.
Merged to master for Apache Spark 3.2.0. Thank you, @wangyum and all.
(The last commit is only adding JIRA id prefix to the test case name.)
Test build #133139 has finished for PR 30849 at commit
|
### What changes were proposed in this pull request? This is a followup of #30849, to fix a correctness issue caused by null value handling. ### Why are the changes needed? Fix a correctness issue. `If(null, true, false)` should return false, not true. ### Does this PR introduce _any_ user-facing change? Yes, but the bug only exist in the master branch. ### How was this patch tested? updated tests. Closes #30953 from cloud-fan/bug. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
Improve
SimplifyConditionals
.Simplify
If(cond, TrueLiteral, FalseLiteral)
tocond
.Simplify
If(cond, FalseLiteral, TrueLiteral)
toNot(cond)
.The use case is:
Before this pr:
After this pr:
Why are the changes needed?
Improve query performance.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.