neilconway commented on code in PR #25479:
URL: https://github.com/apache/datafusion/pull/25479#discussion_r4053363096
##########
datafusion/functions-nested/src/resize.rs:
##########
@@ -269,27 +269,26 @@ fn general_list_resize<O: OffsetSizeTrait + TryInto<i64>>(
count_array,
field,
&original_data,
- &default_value_data,
+ Some(&default_value_data),
output_values_len,
|mutable, _, extra_count| Ok(mutable.try_extend(1, 0,
extra_count)?),
)
} else {
- // Slow path: rows may need different fill values, so append from the
- // corresponding slot in the input fill array for each grown element.
- let fill_values = match default_element {
- Some(fill_values) => fill_values,
- None => {
- let null_scalar = ScalarValue::try_from(&data_type)?;
- null_scalar.to_array_of_size(original_data.len())?
- }
+ // Handle batches with no growth or with different fill values per row.
+ // Growing rows repeat the fill value from their corresponding input
slot.
+ // Growth without a fill argument always takes the bulk path above, so
+ // `default_element` is present whenever a row grows here.
+ let default_value_data = if max_extra > 0 {
+ default_element.map(|fill_values| fill_values.to_data())
+ } else {
+ None
Review Comment:
Thanks for the suggestion! I actually started with the chained filter but I
thought writing it inline was a bit mysterious.
--
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]