Improve InListSImplifier -- add test, commend and avoid clones#8971
Merged
alamb merged 10 commits intoapache:mainfrom Feb 2, 2024
Merged
Improve InListSImplifier -- add test, commend and avoid clones#8971alamb merged 10 commits intoapache:mainfrom
InListSImplifier -- add test, commend and avoid clones#8971alamb merged 10 commits intoapache:mainfrom
Conversation
InListSImplifier -- add test, commend and avoid clones
alamb
commented
Jan 23, 2024
| if l1.expr == l2.expr && l1.negated && l2.negated { | ||
| return inlist_intersection(l1, l2, true); | ||
| } | ||
| if let Expr::BinaryExpr(BinaryExpr { left, op, right }) = expr { |
Contributor
Author
There was a problem hiding this comment.
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> { |
Contributor
Author
There was a problem hiding this comment.
These functions now take owned InList and modify l1 in place
Contributor
Author
|
Clippy failure is due to #8972 |
Contributor
Author
|
@waynexia do you possibly have time to review this PR? |
waynexia
approved these changes
Feb 2, 2024
| ); | ||
| 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) |
Member
There was a problem hiding this comment.
💯 This case shocks me (again) on how powerful this rule is
Contributor
Author
There was a problem hiding this comment.
@jayzhan211 gets all the credit for implementing it in #8949 (🏆)
Contributor
Author
|
Thank you for the review @waynexia 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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