-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25714][SQL][followup] improve the comment inside BooleanSimplification rule #22711
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
| // See the chart: | ||
| // +---------+---------+---------+---------+ | ||
| // | p | q | p OR q | p AND q | | ||
| // | operand | operand | OR | AND | |
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.
AND and OR is commutative, so we can reduce the entries in this table
| // | UNKNOWN | UNKNOWN | UNKNOWN | UNKNOWN | | ||
| // +---------+---------+---------+---------+ | ||
|
|
||
| // This can break if a is null and c is false, so a can't be nullable. |
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.
explain which input can break it, so it's easier to understand.
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.
The current code will not break. Thus, the comment is confusing to the future reader. To make it clear, we can just give the actual value.
(NULL And (NULL Or FALSE)) = NULL, but (NULL And FALSE) = FALSE. Thus, a can't be nullable.
| case (a Or b) And c if !a.nullable && a.semanticEquals(Not(c)) => And(b, c) | ||
| case (a Or b) And c if !b.nullable && b.semanticEquals(Not(c)) => And(a, c) | ||
| // This can break if c is null and b is false, so c can't be nullable. | ||
| case (a Or b) And c if !c.nullable && a.semanticEquals(Not(c)) => And(b, c) |
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.
b.nullable and c.nullable are same, because a.semanticEquals(Not(c)).
|
cc @gatorsmile |
|
Test build #97332 has finished for PR 22711 at commit
|
|
Test build #97334 has finished for PR 22711 at commit
|
|
retest this please |
|
Test build #97342 has finished for PR 22711 at commit
|
…fication rule ## What changes were proposed in this pull request? improve the code comment added in https://github.com/apache/spark/pull/22702/files ## How was this patch tested? N/A Closes #22711 from cloud-fan/minor. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: gatorsmile <gatorsmile@gmail.com> (cherry picked from commit b73f76b) Signed-off-by: gatorsmile <gatorsmile@gmail.com>
|
LGTM Thanks! Merged to master/2.4 |
…fication rule ## What changes were proposed in this pull request? improve the code comment added in https://github.com/apache/spark/pull/22702/files ## How was this patch tested? N/A Closes apache#22711 from cloud-fan/minor. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: gatorsmile <gatorsmile@gmail.com>
What changes were proposed in this pull request?
improve the code comment added in https://github.com/apache/spark/pull/22702/files
How was this patch tested?
N/A