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


##########
datafusion/functions/src/string/starts_with.rs:
##########
@@ -98,6 +99,27 @@ impl ScalarUDFImpl for StartsWithFunc {
         }
     }
 
+    fn simplify(
+        &self,
+        args: Vec<Expr>,
+        _info: &dyn SimplifyInfo,
+    ) -> Result<ExprSimplifyResult> {
+        if let Expr::Literal(ScalarValue::Utf8(Some(pattern))) = &args[1] {
+            // Convert starts_with (col, 'prefix') to col LIKE 'prefix%'
+            let like_pattern = format!("{}%", pattern);

Review Comment:
   I think we probably need to escape any `%` that appears in the pattern (or 
avoid doing this replacement when such a pattern exists)
   
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to