Skip to content

array_concat fails with internal error on mixed List + LargeList inputs #21702

Description

@hcrosse

Describe the bug

Calling array_concat with a mix of List and LargeList arguments hits an internal cast error:

> select array_concat(make_array(1, 2), arrow_cast([3, 4], 'LargeList(Int64)'));
DataFusion error: Internal error: could not cast array of type List(Int64) to arrow_array::array::list_array::GenericListArray<i64>.

The issue is in ArrayConcat::coerce_types (datafusion/functions-nested/src/concat.rs). It uses the return type's base element type to coerce items but leaves the container variant alone, so a List input isn't coerced to LargeList when the return type is LargeList. Then array_concat_inner tries to downcast the List array to GenericListArray<i64> and fails.

Same symptom for FixedSizeList + LargeList.

To Reproduce

select array_concat(make_array(1, 2), arrow_cast([3, 4], 'LargeList(Int64)'));
select array_concat(arrow_cast([1, 2], 'FixedSizeList(2, Int64)'), arrow_cast([3, 4], 'LargeList(Int64)'));

Expected behavior

[1, 2, 3, 4] returned as LargeList(Int64) in both cases (the widest container variant).

Additional context

Surfaced while reviewing #21689, which rewrites concat(array, ...) to array_concat(array, ...) and inherits this limitation for concat(List, LargeList).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions