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


##########
datafusion/functions-nested/src/repeat.rs:
##########
@@ -136,7 +137,17 @@ pub fn array_repeat_inner(args: &[ArrayRef]) -> 
Result<ArrayRef> {
     }
 
     let element = &args[0];
-    let count_array = as_int64_array(&args[1])?;
+    let count_array = &args[1];
+
+    let count_array = match count_array.data_type() {
+        DataType::Int8 | DataType::Int16 | DataType::Int32 => {
+            &cast(count_array, &DataType::Int64)?
+        }
+        DataType::Int64 => count_array,
+        _ => return exec_err!("count must be an integer type"),
+    };
+
+    let count_array = as_int64_array(&count_array)?;

Review Comment:
   if we want the target type of `array_repeat` count function to be `UInt64`, 
we have to change the behaviour of `array_repeat`. As of now, by default 
`count` is of type `Int64`.
   It will be a breaking change, are we okay with that ?
   
   @korowa 
   
   with current implementation of `array_repeat` and `default` data type of 
`Int64` it is behaving like this, if we are converting all `Signed Integer` 
type to `Unsigned Integer`.
   
   ``` sql
   > select array_repeat(1,-20000);
   +--------------------------------------+
   | array_repeat(Int64(1),Int64(-20000)) |
   +--------------------------------------+
   | []                                   |
   +--------------------------------------+
   ```
   Copied behaviour from Spark, as it gives empty arrow for `negative count` 
argument



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