-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Move inlist rule to expr_simplifier #9692
Conversation
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
) => | ||
{ | ||
match (*left, *right) { | ||
(Expr::InList(l1), Expr::InList(l2)) => { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
Thank you @jayzhan211 -- this is a nice cleanup and removes a copy (for node in the expression tree).
I am also running the planning benchmark to see if this PR provides an improvement
// 6. `a in (1,2,3,4) AND a not in (1,2,3,4,5) -> a in (), which is false` | ||
// 7. `a not in (1,2,3,4) AND a in (1,2,3,4,5) -> a = 5` | ||
// 8. `a in (1,2,3,4) AND a not in (5,6,7,8) -> a in (1,2,3,4)` | ||
if let Expr::BinaryExpr(BinaryExpr { left, op, right }) = expr.clone() { |
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.
Removing this expr.clone()
is 👍
Transformed::yes(Expr::InList(merged_inlist)) | ||
} | ||
|
||
// Simplify expressions that is guaranteed to be true or false to a literal boolean expression |
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.
👨🍳 👌 -- very nice
@@ -1482,6 +1590,22 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for Simplifier<'a, S> { | |||
} | |||
} | |||
|
|||
// TODO: We might not need this after defer pattern for Box is stabilized. https://github.com/rust-lang/rust/issues/87121 |
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.
👍
Testing with git checkout inlist-rule2
cargo bench --bench sql_planner -- all
#alamb@aal-dev:~/arrow-datafusion4$ git merge-base HEAD apache/main
#b0b329ba39403b9e87156d6f9b8c5464dc6d2480
git checkout b0b329ba39403b9e87156d6f9b8c5464dc6d2480
cargo bench --bench sql_planner -- all |
I did not measure any significant difference in performance on the |
I doubt if even the rule is included. |
Which issue does this PR close?
Closes #9140.
I think short inlist simplifier should be an independent simplifier that can't be moved to simplifier, so that it will only be run once after all the other inlist simplification. Therefore, close the issue.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?