Jefffrey commented on code in PR #18363:
URL: https://github.com/apache/datafusion/pull/18363#discussion_r2476748405
##########
datafusion/functions-nested/src/flatten.rs:
##########
@@ -154,7 +158,32 @@ pub fn flatten_inner(args: &[ArrayRef]) ->
Result<ArrayRef> {
Ok(Arc::new(flattened_array) as ArrayRef)
}
LargeList(_) => {
- exec_err!("flatten does not support type '{:?}'",
array.data_type())?
+ let (inner_field, inner_offsets, inner_values, _) =
+ as_large_list_array(&values)?.clone().into_parts();
+ // Try to downcast the inner offsets to i32
+ match downcast_i64_inner_to_i32(&inner_offsets, &offsets) {
+ Ok(i32offsets) => {
+ let flattened_array = GenericListArray::<i32>::new(
+ inner_field,
+ i32offsets,
+ inner_values,
+ nulls,
+ );
+ Ok(Arc::new(flattened_array) as ArrayRef)
+ }
+ // If downcast fails we keep the offsets as is
+ Err(_) => {
+ // Fallback: keep i64 offsets → LargeList<i64>
+ let i64offsets = keep_offsets_i64(inner_offsets,
offsets);
+ let flattened_array = GenericListArray::<i64>::new(
+ inner_field,
+ i64offsets,
+ inner_values,
+ nulls,
+ );
+ Ok(Arc::new(flattened_array) as ArrayRef)
Review Comment:
Yep I did mention that, however I did make a note that:
> though this might be tricky considering `return_type()` wouldn't know this
until execution
I think we make a choice, either always upcast to large if one of the inner
lists is a large list, or just error.
I guess the former is more favourable/robust than the latter.
--
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]