-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 queries filtering for the same condition with both an IN and EQUALS to not return empty results #16597
Fix queries filtering for the same condition with both an IN and EQUALS to not return empty results #16597
Conversation
{ | ||
public FixIncorrectInExpansionTypes() | ||
{ | ||
super(operand(RelNode.class, any())); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
RelOptRule.operand
{ | ||
public FixIncorrectInExpansionTypes() | ||
{ | ||
super(operand(RelNode.class, any())); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
RelOptRule.any
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 suspect the PR description is not accurate; it says:
current approach is to run the ReduceExpressionRule early to get rid of the problematic issue
but that does not seem to be what is happening. Could you please clarify what the bug is and how we're fixing it?
public RexNode visitCall(RexCall call) | ||
{ | ||
RexNode newNode = super.visitCall(call); | ||
if (newNode.getKind() == SqlKind.EQUALS) { |
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.
is this really only needed for EQUALS
? what about NOT_EQUALS
, GREATER_THAN
, etc? what about other kinds of operations on strings?
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.
to raise the current error:
- a literal generated by that part in
SqlToRel
for anIN
expression orNOT IN
- a comparision with
equals
should happen inRexSimplify
I've tried a few queries with not in ; and they were not able to trigger the issue.
but I've added NOT_EQUALS
as there might be some twisted case just in case...
thank you for noticing this! that would have been the easiest to fix it - however it had some adverse effects; so I've decided to write a custom rule instead. (updated the desc) |
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.
Looks good. Quick qsn - Can we have the sqlToRelWorkaroundProgram
to have multiple temporary rules in case if we need similar rules rather than a singleton list or we need to have a new Program
?
thank you @sreemanamala for taking a look; I expect this |
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.
Tried a few queries. All passed. PR lgtm.
…LS to not return empty results (apache#16597) temp fix until CALCITE-6435 gets fixed (released&upgraded to) added a custom rule (FixIncorrectInExpansionTypes) to fix-up types of the affected literals added a testcase which will alert on upgrade
FixIncorrectInExpansionTypes
) to fix-up types of the affected literalsRelease note
Queries filtering for the same string value with both an IN expression and an = filter may have been incorrectly returned an empty resultset.
This PR has: