oc7o commented on code in PR #23188:
URL: https://github.com/apache/datafusion/pull/23188#discussion_r3500428403


##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -1099,6 +1099,20 @@ pub fn binary(
     Ok(Arc::new(BinaryExpr::new(lhs, op, rhs)))
 }
 
+fn sql_similar_to_regex(pattern: &str) -> String {
+    let mut result = String::with_capacity(pattern.len() + 6);
+    result.push_str("^(?:");
+    for ch in pattern.chars() {
+        match ch {
+            '%' => result.push_str(".*"),
+            '_' => result.push('.'),
+            c => result.push(c),

Review Comment:
   `| * + ? ( ) { } [ ]` are POSIX metacharacters that SIMILAR TO also defines. 
I've reworked the translator to escape only . ^ $ \ (the regex-only metachars) 
and pass the POSIX ones through to the regex. Updated tests cover both 
directions.



-- 
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