-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: Avoid mistaken ILike to string equality optimization #15836
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
Conversation
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.
@comphead It isn't parser related, it's a bug in evaluation, with this optimizer. It seems a query like Here is a complete program that reproduces this on 46.0.1:
Output on 46.0.1 (before applying this change)
|
Thanks @srh for providing the test case please add the query to one of |
.contains(['%', '_', escape_char].as_ref()) => | ||
if !like.case_insensitive | ||
&& !pattern_str | ||
.contains(['%', '_', escape_char].as_ref()) => | ||
{ | ||
// If the pattern does not contain any wildcards, we can simplify the like expression to an equality expression | ||
// TODO: handle escape characters |
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 like we have completed the TODO as well -- can yoy remove this 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.
I think that comment is referring to parsing escape characters and performing the optimization on strings with character escapes too.
Thank you for this PR @srh |
I have added a test case (not the one with an inner select, because there is a table already set up to use with a non-constant expression) and have confirmed it fails when the fix is reverted. |
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 @srh - this looks good to me
@@ -115,6 +115,12 @@ p1 | |||
p1e1 | |||
p1m1e1 | |||
|
|||
query T rowsort |
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.
In case anyone is curious, without the fix this test fails like this:
Completed 1 test files in 0 seconds External error: query result mismatch:
[SQL] SELECT s FROM test WHERE s ILIKE 'p1';
[Diff] (-expected|+actual)
- P1
p1
at test_files/strings.slt:118
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 @srh for your contribution.
* fix: Avoid mistaken ILike to string equality optimization * test: ILIKE without wildcards
Which issue does this PR close?
Rationale for this change
Bugfix
What changes are included in this PR?
Bugfix and unit test cases for the optimization.
Are these changes tested?
Yes.
Are there any user-facing changes?
This changes the behavior of ILIKE.