Uh oh!
There was an error while loading. Please reload this page.
feat: support array_resize - #8744
Conversation
There was a problem hiding this comment.
This looks good to me, but I have a different idea about array_size.
We can apply the combination of existing array_length, array_slice, array_repeat and array_concat to resize the array. But I'm not sure is it faster or slower, is it easier to maintain or not. How do you think about this approach @Weijun-H ?
array_concat(array_slice(array, 0, min(array_length, count)), array_repeat(default_array, max(count-array_length), 0))
| for (index, arr) in array.iter().enumerate() { | ||
| let count = count_array.value(index).to_usize().ok_or_else(|| { | ||
| DataFusionError::Execution( |
| array: &GenericListArray<O>, | ||
| count_array: &Int64Array, | ||
| field: &FieldRef, | ||
| new_element: Option<ArrayRef>, |
There was a problem hiding this comment.
default_element might be more concise?
Uh oh!
There was an error while loading. Please reload this page.
I think this approach is not a better idea, as supporting the column for |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
comphead
commented
Jan 7, 2024
thanks @Weijun-H I'll review it tomorrow more closely if no one else beats me. |
| let new_rows = vec![&default_value; count - remain_count]; | ||
| rows.extend(new_rows); | ||
| let last_offset = offsets.last().copied().unwrap(); |
There was a problem hiding this comment.
Please handle the potential error on .unwrap
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
This comment was marked as outdated.
e66acd6 to
cba3269CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| for (row_index, offset_window) in array.offsets().windows(2).enumerate() { | ||
| let count = count_array.value(row_index).to_usize().ok_or_else(|| { | ||
| exec_datafusion_err!("array_resize: failed to convert size to usize") |
There was a problem hiding this comment.
does type conversion more like internal_err?
wasn't expected/anticipated by the implementation and that is most likely a bug (the error message even encourages users to open a bug report)
unlike array.len() != number, which is error from user.
jayzhan211
left a comment
There was a problem hiding this comment.
Much better with MutableArray! LGTM
Which issue does this PR close?
Closes#7194
Rationale for this change
array_resizeLargeListWhat changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?