Jefffrey commented on code in PR #20459:
URL: https://github.com/apache/datafusion/pull/20459#discussion_r2839166118
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -3434,13 +3434,22 @@ impl ScalarValue {
}
}
+ /// Repeats the rows of `arr` `size` times, producing an array with
+ /// `arr.len() * size` total rows.
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));
+ }
+
+ // Examples: given `arr = [[A, B, C]]` and `size = 3`, `indices = [0,
0, 0]` and
+ // the result is `[[A, B, C], [A, B, C], [A, B, C]]`.
+ //
+ // Given `arr = [[A, B], [C]]` and `size = 2`, `indices = [0, 1, 0,
1]` and the
+ // result is `[[A, B], [C], [A, B], [C]]`. (But in practice, we are
always called
Review Comment:
Would it be better to explicitly check that `arr.len() == 1` so we don't
need to cover edge cases that aren't meant to occur? (Which can lead to a bit
simpler/readable code here)
--
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]