comphead commented on code in PR #20459:
URL: https://github.com/apache/datafusion/pull/20459#discussion_r2836879244


##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -3435,12 +3435,13 @@ impl ScalarValue {
     }
 
     fn list_to_array_of_size(arr: &dyn Array, size: usize) -> Result<ArrayRef> 
{
-        let arrays = repeat_n(arr, size).collect::<Vec<_>>();
-        let ret = match !arrays.is_empty() {
-            true => arrow::compute::concat(arrays.as_slice())?,
-            false => arr.slice(0, 0),
-        };
-        Ok(ret)
+        if size == 0 {
+            return Ok(arr.slice(0, 0));
+        }
+
+        let n = arr.len() as u32;
+        let indices = UInt32Array::from_iter_values((0..size).flat_map(|_| 
0..n));

Review Comment:
   perhaps we can document here 
   
   ```
   Suppose inner array is [A, B, C] and you want size=3:
   
   indices becomes: [0,1,2, 0,1,2, 0,1,2]
   take produces: [A,B,C, A,B,C, A,B,C]
   ```



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

Reply via email to