Uh oh!
There was an error while loading. Please reload this page.
[SPARK-29162][SQL] Simplify NOT(IsNull(x)) and NOT(IsNotNull(x)) - #25878
[SPARK-29162][SQL] Simplify NOT(IsNull(x)) and NOT(IsNotNull(x))#25878AngersZhuuuu wants to merge 10 commits into
Conversation
AngersZhuuuu
commented
Sep 21, 2019
gentle ping @juliuszsompolski |
| Literal.create(null, e.dataType) | ||
| case n@Not(expr: IsNull) => IsNotNull(expr.child) | ||
| case n@Not(expr: IsNotNull) => IsNull(expr.child) |
There was a problem hiding this comment.
Why do you handle this in NullPropagation?
There was a problem hiding this comment.
Also, plz check the code style carefully?
There was a problem hiding this comment.
Also, plz check the code style carefully?
Sorry, forget to check this place...
There was a problem hiding this comment.
Why do you handle this in NullPropagation?
Don't found other better place, and it's also NULL expression problem.
Or add a new class?
HyukjinKwon
commented
Sep 21, 2019
ok to test |
SparkQA
commented
Sep 21, 2019
Test build #111122 has finished for PR 25878 at commit
|
| } | ||
| case n @ Not(expr: IsNull) => IsNotNull(expr.child) | ||
| case n @ Not(expr: IsNotNull) => IsNull(expr.child) |
| } | ||
| private def assertFilter(originalExpr: Expression, | ||
| expectedExpr: Expression): Unit = { |
| e.copy(branches = branches.take(i).map(branch => (branch._1, elseValue))) | ||
| } | ||
| case n @ Not(expr: IsNull) => IsNotNull(expr.child) |
There was a problem hiding this comment.
IsNull and IsNotNull are conditional expressions? Seems BooleanSimplification is more suitable.
There was a problem hiding this comment.
conditional
Reasonable, I focus too much on isnull/isnotnull expression。
| } | ||
| } | ||
| test("SPARK-29152: Simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") { |
There was a problem hiding this comment.
nit: I personally think the SimplifyConditionalSuite test is enough for this fix.
There was a problem hiding this comment.
nit: I personally think the
SimplifyConditionalSuitetest is enough for this fix.
Yeah, seems end-to-end test in SQLQuerySuit is redundant
| } | ||
| test("simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") { | ||
| assertFilter(Not(IsNotNull(UnresolvedAttribute("b"))), IsNull(UnresolvedAttribute("b"))) |
There was a problem hiding this comment.
We cannot use assertEquivalent here?
There was a problem hiding this comment.
We cannot use
assertEquivalenthere?
assertEquivalent use OneRowRelation, no column, so I add a testRelation.
I will remove it to BooleanSimplificationSuit .
| case Not(Not(e)) => e | ||
| case Not(expr: IsNull) => IsNotNull(expr.child) | ||
| case Not(expr: IsNotNull) => IsNull(expr.child) |
There was a problem hiding this comment.
nit. expr -> e.
case Not(e: IsNull) => IsNotNull(e.child)
case Not(e: IsNotNull) => IsNull(e.child)
There was a problem hiding this comment.
nit.
expr->e.
How about
case Not(IsNull(e)) => IsNotNull(e)
case Not(IsNotNull(e)) => IsNull(e)
| test("simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") { | ||
| checkCondition(Not(IsNotNull(UnresolvedAttribute("b"))), IsNull(UnresolvedAttribute("b"))) | ||
| checkCondition(Not(IsNull(UnresolvedAttribute("b"))), IsNotNull(UnresolvedAttribute("b"))) | ||
| } |
There was a problem hiding this comment.
@AngersZhuuuu . Since you are active contribution, I'd like to recommend to use DSL as possible as you can. (Please refer the other tests.)
test("simplify NOT(IsNull(x)) and NOT(IsNotNull(x))") {
checkCondition(Not(IsNotNull('e)), IsNull('e))
checkCondition(Not(IsNull('e)), IsNotNull('e))
}There was a problem hiding this comment.
@AngersZhuuuu . Since you are active contribution, I'd like to recommend to use DSL as possible as you can. (Please refer the other tests.)
First time use DSL, I will get to know DSL more
dongjoon-hyun
commented
Sep 22, 2019
@AngersZhuuuu . Thank you for your contributions. I left two minor comments. Please address them. |
AngersZhuuuu
commented
Sep 22, 2019
Thank you for your advise. All for better job. |
SparkQA
commented
Sep 22, 2019
Test build #111131 has finished for PR 25878 at commit
|
SparkQA
commented
Sep 22, 2019
Test build #111133 has finished for PR 25878 at commit
|
SparkQA
commented
Sep 22, 2019
Test build #111142 has finished for PR 25878 at commit
|
AngersZhuuuu
commented
Sep 22, 2019
Can you trigger restart test. Thanks . |
maropu
commented
Sep 22, 2019
retest this please |
SparkQA
commented
Sep 22, 2019
Test build #111156 has finished for PR 25878 at commit
|
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Merged to master. Thank you all!
What changes were proposed in this pull request?
Rewrite
Why are the changes needed?
Make LogicalPlan more readable and useful for query canonicalization. Make same condition equal when judge query canonicalization equal
Does this PR introduce any user-facing change?
NO
How was this patch tested?
Newly added UTs.