-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Test LIKE with implicit \
escape
#13288
Test LIKE with implicit \
escape
#13288
Conversation
# if "%%" in the pattern was simplified to "%", the pattern semantics would change | ||
# same as above query, but with data coming from a table, so that constant folding cannot kick in, but expression simplification can | ||
query TB | ||
SELECT a, a LIKE '\%%' FROM inputs | ||
---- | ||
% true | ||
%% true | ||
\%% false | ||
%abc true | ||
\%abc 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.
This would prevent a regression #13260 (comment)
VALUES ('\'), ('\\'), ('\\\'), ('\\\\') | ||
---- | ||
\ | ||
\\ | ||
\\\ | ||
\\\\ |
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 query (and all other queries involving a \
backslash) would behave differently in the CLI
#13286
@@ -829,3 +838,95 @@ SELECT | |||
'a' LIKE '%' | |||
---- | |||
NULL true true | |||
|
|||
# \ is an implicit escape character |
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.
When working on #13260 i didn't know that \ is an implicit escape character. I couldn't find any tests for this, so here they come.
true true false true false | ||
|
||
statement ok | ||
create table inputs AS SELECT * FROM (VALUES ('%'), ('%%'), ('\%%'), ('%abc'), ('\%abc')) t(a); |
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.
Testing below query with VALUES should be enough... unless/until we have "push projection into values" optimization.
Maybe i should replace this with non-inlinable values using random?
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.
Testing below query with VALUES should be enough... unless/until we have "push projection into values" optimization.
I don't understand this -- there is only one column (t
) and the query selects that column -- so there is no projection to push down 🤔
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.
it was for the case in which the inputs
were not a table, but just VALUES ...
f33b075
to
86abe17
Compare
('%', '\%', '', ''), | ||
('_', '\_', '', ''), |
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 feels duplicate with what i added in string_literal, but adds test coverage for all string variants
d7de2e4
to
6c7d6ae
Compare
6c7d6ae
to
aea67f1
Compare
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.
aea67f1
to
6dd5744
Compare
\a \\a false | ||
\a % true | ||
\a \% false | ||
\a \\% 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.
This one looks like a bug.
Given \
is an escape character, \\
should match single backslash character \
of the input,
and %
should match the rest (a
). The result should be true
then
\\\\ \\a false | ||
\\\\ % true | ||
\\\\ \% false | ||
\\\\ \\% 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.
This one looks like a bug.
Given \
is an escape character, \\
should match single backslash character \
of the input,
and %
should match the rest (\\\
). The result should be true
then
@goldmedal added a few more test cases. Marked examples #13288 (comment) #13288 (comment) |
6dd5744
to
bc54c50
Compare
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 @findepi and @goldmedal -- I think this does a great job documenting what our current LIKE behavior is. 🚀
true true false true false | ||
|
||
statement ok | ||
create table inputs AS SELECT * FROM (VALUES ('%'), ('%%'), ('\%%'), ('%abc'), ('\%abc')) t(a); |
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.
Testing below query with VALUES should be enough... unless/until we have "push projection into values" optimization.
I don't understand this -- there is only one column (t
) and the query selects that column -- so there is no projection to push down 🤔
More tests before #13260 lands.
Would prevent regression #13260 (comment)