jayzhan211 commented on code in PR #14812:
URL: https://github.com/apache/datafusion/pull/14812#discussion_r1969204488


##########
datafusion/functions/src/string/starts_with.rs:
##########
@@ -23,15 +23,19 @@ use arrow::datatypes::DataType;
 use datafusion_expr::simplify::{ExprSimplifyResult, SimplifyInfo};
 
 use crate::utils::make_scalar_function;
+use datafusion_common::types::logical_string;
 use datafusion_common::{internal_err, Result, ScalarValue};
-use datafusion_expr::{ColumnarValue, Documentation, Expr, Like};
-use datafusion_expr::{ScalarFunctionArgs, ScalarUDFImpl, Signature, 
Volatility};
+use datafusion_expr::{
+    cast, Coercion, ColumnarValue, Documentation, Expr, Like, 
ScalarFunctionArgs,
+    ScalarUDFImpl, Signature, TypeSignatureClass, Volatility,
+};
 use datafusion_macros::user_doc;
 
 /// Returns true if string starts with prefix.
 /// starts_with('alphabet', 'alph') = 't'
 pub fn starts_with(args: &[ArrayRef]) -> Result<ArrayRef> {
-    let result = arrow::compute::kernels::comparison::starts_with(&args[0], 
&args[1])?;
+    let arg0 = arrow::compute::kernels::cast::cast(&args[0], 
args[1].data_type())?;

Review Comment:
   I think better to use `string_coercion` and `binary_to_string_coercion`



##########
datafusion/functions/src/string/starts_with.rs:
##########
@@ -127,7 +137,7 @@ impl ScalarUDFImpl for StartsWithFunc {
 
             return Ok(ExprSimplifyResult::Simplified(Expr::Like(Like {
                 negated: false,
-                expr: Box::new(args[0].clone()),
+                expr: Box::new(cast(args[0].clone(), 
scalar_value.data_type())),

Review Comment:
   I think better to use string_coercion and binary_to_string_coercion



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