-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-32721][SQL] Simplify if clauses with null and boolean #29567
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
f9e87f0
e4d929c
bb7c38c
cc66198
60e0e92
2b90c19
71bd033
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 |
---|---|---|
|
@@ -221,14 +221,14 @@ class BooleanSimplificationSuite extends PlanTest with ExpressionEvalHelper with | |
|
||
test("Complementation Laws - null handling") { | ||
checkCondition('e && !'e, | ||
testRelationWithData.where(If('e.isNull, Literal.create(null, BooleanType), false)).analyze) | ||
testRelationWithData.where(And(Literal(null, BooleanType), 'e.isNull)).analyze) | ||
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. Although I think it is better to test 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. Yeah. What is the recommended way for adding test suite for optimizers? should each test suite only use the corresponding optimizer rule, or it's OK to also add those relevant ones? 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. Usually we only test corresponding rule in each test suite. But some suites use multiple rules like this one. For this one, although we can still only test |
||
checkCondition(!'e && 'e, | ||
testRelationWithData.where(If('e.isNull, Literal.create(null, BooleanType), false)).analyze) | ||
testRelationWithData.where(And(Literal(null, BooleanType), 'e.isNull)).analyze) | ||
|
||
checkCondition('e || !'e, | ||
testRelationWithData.where(If('e.isNull, Literal.create(null, BooleanType), true)).analyze) | ||
testRelationWithData.where(Or('e.isNotNull, Literal(null, BooleanType))).analyze) | ||
checkCondition(!'e || 'e, | ||
testRelationWithData.where(If('e.isNull, Literal.create(null, BooleanType), true)).analyze) | ||
testRelationWithData.where(Or('e.isNotNull, Literal(null, BooleanType))).analyze) | ||
} | ||
|
||
test("Complementation Laws - negative case") { | ||
|
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.
what about the other way around? e.g.
case If(cond, FalseLiteral, l @ Literal(null, _))
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.
ah it's covered in the followup #29603