alamb commented on code in PR #13288:
URL: https://github.com/apache/datafusion/pull/13288#discussion_r1833133591


##########
datafusion/sqllogictest/test_files/string/string_literal.slt:
##########
@@ -829,3 +838,95 @@ SELECT
     'a' LIKE '%'
 ----
 NULL true true
+
+# \ is an implicit escape character
+query BBBB
+SELECT
+    'a' LIKE '\%',
+    '\a' LIKE '\%',
+    '%' LIKE '\%',
+    '\%' LIKE '\%'
+----
+false false true false
+
+# \ is an implicit escape character
+query BBBBBB
+SELECT
+    'a' LIKE '\_',
+    '\a' LIKE '\_',
+    '_' LIKE '\_',
+    '\_' LIKE '\_',
+    'abc' LIKE 'a_c',
+    'abc' LIKE 'a\_c'
+----
+false false true false true false
+
+# \ as an explicit escape character is currently not supported
+query error DataFusion error: SQL error: ParserError\("Expected end of 
statement, found: \\\\"\)
+SELECT
+    'a' LIKE '\%' ESCAPE '\',
+    '\a' LIKE '\%' ESCAPE '\',
+    '%' LIKE '\%' ESCAPE '\',
+    '\%' LIKE '\% ESCAPE '\''
+
+# \ as an explicit escape character is currently not supported
+query error DataFusion error: Execution error: LIKE does not support 
escape_char
+SELECT
+    'a' LIKE '\_' ESCAPE '\',
+    '\a' LIKE '\_' ESCAPE '\',
+    '_' LIKE '\_' ESCAPE '\',
+    '\_' LIKE '\_' ESCAPE '\',
+    'abc' LIKE 'a_c' ESCAPE '\',
+    'abc' LIKE 'a\_c' ESCAPE '\'
+
+# a LIKE pattern containing escape can never match an empty string
+query BBBBB
+SELECT
+    '' LIKE '\',
+    '' LIKE '\\',
+    '' LIKE '\_',
+    '' LIKE '\%',
+    '' LIKE '\a'
+----
+false false false false false
+
+# escape before non-wildcard matches the escape itself
+query BBBBBBB
+SELECT
+    'a' LIKE '\a',
+    '\a' LIKE '\a',
+    '\a' LIKE '\b',
+    '\' LIKE '\',
+    '\\' LIKE '\',
+    '\' LIKE '\\',
+    '\\' LIKE '\\'
+----
+false true false true false false true
+
+# if "%%" in the pattern was simplified to "%", the pattern semantics would 
change
+query BBBBB
+SELECT
+    '%' LIKE '\%%',
+    '%%' LIKE '\%%',
+    '\%%' LIKE '\%%',
+    '%abc' LIKE '\%%',
+    '\%abc' LIKE '\%%'
+----
+true true false true false
+
+statement ok
+create table inputs AS SELECT * FROM (VALUES ('%'), ('%%'), ('\%%'), ('%abc'), 
('\%abc')) t(a);

Review Comment:
   > 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 🤔 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to