-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improve InListSImplifier -- add test, commend and avoid clones
#8971
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
InListSImplifier -- add test, commend and avoid clones
| if l1.expr == l2.expr && l1.negated && l2.negated { | ||
| return inlist_intersection(l1, l2, true); | ||
| } | ||
| if let Expr::BinaryExpr(BinaryExpr { left, op, right }) = expr { |
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.
This pattern allows getting an owned left and right and avoiding the clone
| Ok(Expr::InList(merged_inlist)) | ||
| /// Return the union of two inlist expressions | ||
| /// maintaining the order of the elements in the two lists | ||
| fn inlist_union(mut l1: InList, l2: InList, negated: bool) -> Result<Expr> { |
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.
These functions now take owned InList and modify l1 in place
|
Clippy failure is due to #8972 |
|
@waynexia do you possibly have time to review this PR? |
waynexia
left a 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.
LGTM 👍 These changes are great @alamb
| ); | ||
| assert_eq!(simplify(expr.clone()), lit(true)); | ||
|
|
||
| // 3.5 c1 NOT IN (1, 2, 3, 4) OR c1 NOT IN (4, 5, 6, 7) -> c1 != 4 (4 overlaps) |
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.
💯 This case shocks me (again) on how powerful this rule is
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.
@jayzhan211 gets all the credit for implementing it in #8949 (🏆)
|
Thank you for the review @waynexia 🙏 |
Which issue does this PR close?
Follow on to #8949
Rationale for this change
During review I noticed another test that would be good as well as a few places we could avoid a clone (see https://github.com/apache/arrow-datafusion/pull/8949/files#r1462605147 )
What changes are included in this PR?
Are these changes tested?
Yes, by existing tests
Are there any user-facing changes?
No