tshauck commented on code in PR #11787:
URL: https://github.com/apache/datafusion/pull/11787#discussion_r1702161338


##########
datafusion/functions/src/string/starts_with.rs:
##########
@@ -81,18 +106,73 @@ impl ScalarUDFImpl for StartsWithFunc {
     }
 
     fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
-        use DataType::*;
-
-        Ok(Boolean)
+        Ok(DataType::Boolean)
     }
 
     fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
         match args[0].data_type() {
             DataType::Utf8 => make_scalar_function(starts_with::<i32>, 
vec![])(args),
-            DataType::LargeUtf8 => {
-                return make_scalar_function(starts_with::<i64>, vec![])(args);
-            }
-            _ => internal_err!("Unsupported data type"),
+            DataType::LargeUtf8 => make_scalar_function(starts_with::<i64>, 
vec![])(args),
+            DataType::Utf8View => make_scalar_function(starts_with::<i32>, 
vec![])(args),
+            _ => internal_err!("Unsupported data types for starts_with")?,
         }
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use crate::utils::test::test_function;
+    use arrow::array::{Array, BooleanArray};
+    use arrow::datatypes::DataType::Boolean;
+    use datafusion_common::{Result, ScalarValue};
+    use datafusion_expr::{ColumnarValue, ScalarUDFImpl};
+
+    use super::*;
+
+    #[test]
+    fn test_functions() -> Result<()> {
+        // Generate test cases for starts_with
+        let test_cases = vec![

Review Comment:
   Not sure if this is the best way to test this change. It tests the function 
but doesn't a view wouldn't be coerced.



##########
datafusion/functions/src/string/starts_with.rs:
##########
@@ -53,16 +76,18 @@ impl Default for StartsWithFunc {
 impl StartsWithFunc {
     pub fn new() -> Self {
         use DataType::*;
+
+        let string_types = vec![Utf8, LargeUtf8, Utf8View];
+        let mut type_signatures = vec![];
+
+        for left in &string_types {

Review Comment:
   Not sure if there's a better way to do this? Maybe I should just list them 
out?



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