oc7o commented on code in PR #23188:
URL: https://github.com/apache/datafusion/pull/23188#discussion_r3500246815
##########
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:
True, I thought that it would be reasonable to also pass regex but we should
just stick with vanilla SQL syntax. This is the way a user would expect it to
be. The translator now escapes all non-wildcard characters.
This is also how the PostgreSQL docs expect it to be
(https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-SIMILARTOREGEXP)
##########
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(".*"),
Review Comment:
Wow that's very attentive. I'd never have thought of that! Switched to
`(?s:.*)` and `(?s:.)` and added a regression test.
--
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]