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 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: [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]