korowa commented on code in PR #14236:
URL: https://github.com/apache/datafusion/pull/14236#discussion_r1927495321


##########
datafusion/functions-nested/src/repeat.rs:
##########
@@ -124,19 +125,47 @@ impl ScalarUDFImpl for ArrayRepeat {
         &self.aliases
     }
 
+    fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
+        if arg_types.len() != 2 {
+            return exec_err!("array_repeat expects two arguments");
+        }
+
+        let element_type = &arg_types[0];
+        let first = element_type.clone();
+
+        let count_type = &arg_types[1];
+
+        // Coerce the second argument to Int64/UInt64 if it's a numeric type
+        let second = match count_type {
+            DataType::Int8 | DataType::Int16 | DataType::Int32 | 
DataType::Int64 => {

Review Comment:
   Non-necessary suggestion: due to safe cast converting negative values to 
nulls, perhaps we should also add a simple test to verify that count array with 
multiple values with nulls (after casting to uint) will be processed as 
expected, like
   ```sql
   select array_repeat('x', column1) from (values (-1), (2), (-3));
   ```



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