-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: not do boolean folding on NULL and/or expr #1245
Conversation
@alamb and @matthewmturner Can you help review this? |
Thanks for your nice work 🎉@NGA-TRAN FYI case1
postgres=# select 11 BETWEEN 0 AND 10 and NULL as c;
c
---
f
(1 row)
case2
postgres=# select 1 BETWEEN 0 AND 10 and NULL as c;
c
---
(1 row)
case3
postgres=# select 1 BETWEEN 0 AND 10 or NULL as c;
c
---
t
(1 row)
case4
postgres=# select 11 BETWEEN 0 AND 10 or NULL as c;
c
---
(1 row) So I think we can add two tests about case1 and case4. @NGA-TRAN |
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 @NGA-TRAN -- I find the new structure and comments much easier to follow.
// FALSE and expr (including NULL) = FALSE | ||
Some(false) => Expr::Literal(ScalarValue::Boolean(Some(false))), | ||
None => match *bool_expr { | ||
// NULL and TRUE = 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.
FWIW I am working on getting these constant cases to work with the ConstEvaluator
(so they wouldn't be strictly necessary) but it turns out these types of expressions don't actually work in the general evaluator
I am working on it in #1163
But in any event I think this code is good 👍
@xudong963 Those are great queries. I have tried to add them in the test but I think we have not done constant folding for I can open a new ticket for improving these cases though. What do you think @alamb ? |
@alamb I have addressed the comments. It should be ready for merge when all checks pass |
I think the constant folding is handled by The fact we have some boolean constant evaluation in here is a historical artifact and due to the fact we don't have full expression evaluation support for all boolean operations (yet). Thus I don't think a separate ticket is needed |
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 @NGA-TRAN
Which issue does this PR close?
Closes #1244
Rationale for this change
Do not fold
Boolean(NULL) and/or expr
because it depends on the value of theexpr
What changes are included in this PR?
Boolean(NULL) and/or expr
is key as-is (aka not rewrite)Are there any user-facing changes?
This bug was hit by IOx's storage_api::test