-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-4910] Enhance simplify to reduce ((A OR D) and (A OR C) AND A AND B) to (A AND B) (Ziwei Liu) #2673
base: main
Are you sure you want to change the base?
Conversation
9930411
to
46337f7
Compare
…A AND B) to (A AND B) (Ziwei Liu)
46337f7
to
93bc40e
Compare
@xiayutianwei1994 Until we have a final state, please don't force push the commit before that. |
Ok, Thanks |
// package-protected only to support a deprecated method; treat as private | ||
RexNode simplifyAnd2(List<RexNode> terms, List<RexNode> notTerms) { | ||
Set<RexNode> termsSet = new HashSet<>(terms); |
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.
I think we already have similar logic here - based on the predicates - and most likely we only miss the handling of an existing predicate somewhere around in the simplifyIsNull/simpliftIsNotNull
methods
I think this approach is a little bit too much by the way as at first glance I would be afraid that it would make "unsafe" simplifications as well
let me know if you think otherwise - I'll try to take a closer look tomorrow
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 for your comment.
If use unknown as unknown, some predicate will not be simplified to IS NOT NULL or IS NULL like the third test case I added.
There also has another question: If (A OR B) AND A, predicate A is nondeterministic, whether it can be simplified to A. I think is can not be simplified.
Now we only pull up predicate which is deterministic.
If the upper question's answer is can not simplify, change some code in simplifyIsNull/simpliftIsNotNull
may handle this logic when unknown as false.
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.
I have updated the code, please review it again.
Thanks very much.
I have updated the code, please review it again. |
8a5cf83
to
cf7f71b
Compare
Enhance simplify to reduce ((A OR D) AND (A OR C) AND A AND B) to (A AND B) (Ziwei Liu)