-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Enable inlist support for preimage #20051
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
base: main
Are you sure you want to change the base?
Conversation
masonh22
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.
This looks good, one small comment
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
Outdated
Show resolved
Hide resolved
|
Thanks for your review @masonh22. I am thinking about |
Hmmm, I see that you are already checking whether the list contains null and not applying the rule in that case. I'm not really sure what the semantics are for null values in InList. I see that Does that make sense? Is that what you were thinking about? |
|
If we pass a When looping through the expressions in the list we would check if But I don't think this is relevant because if you want |
|
Oh right I see what you mean. I think you could skip over nulls while looping over the expressions but I don't think you need to add |
comphead
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.
Thanks @sdf-jkl please help me to understand how inlist preimage is different from datafusion/optimizer/src/simplify_expressions/inlist_simplifier.rs
And if it is, maybe the file above would be the better place for InList ?
|
@comphead The issue with existing inlist_simplifier.rs is this guard: }) = expr
&& !list.is_empty()
&& (
// For lists with only 1 value we allow more complex expressions to be simplified
// e.g SUBSTR(c1, 2, 3) IN ('1') -> SUBSTR(c1, 2, 3) = '1'
// for more than one we avoid repeating this potentially expensive
// expressions
list.len() == 1
|| list.len() <= THRESHOLD_INLINE_INLIST
&& expr.try_as_col().is_some() // <--- this point here
)When I was thinking about adding support inside There is an issue for that: |
Which issue does this PR close?
Rationale for this change
Check issue
What changes are included in this PR?
Match arm to support preimage for InList expressions in expr_simplifier.rs
Are these changes tested?
Yes, added two tests for
IN LISTandNOT IN LISTsupport.Are there any user-facing changes?
No