Commit e524f49
authored
fix: array_concat widens container variant for mixed List/LargeList inputs (#21704)
## Which issue does this PR close?
- Closes #21702.
## Rationale for this change
`array_concat` hit an internal cast error when given a mix of `List` and
`LargeList` (or `FixedSizeList` and `LargeList`) arguments:
```sql
> 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>.
```
`ArrayConcat::coerce_types` was coercing only the base element type,
leaving the outer container alone. When the resolved return type is
`LargeList`, `array_concat_inner` later tries to downcast each arg to
`GenericListArray<i64>`, which fails for any `List` argument that
slipped through.
## What changes are included in this PR?
In `ArrayConcat::coerce_types`, after coercing the base type, also
promote each input's outermost `List` to `LargeList` when the return
type is a `LargeList`. `FixedSizeList` inputs already go through
`FixedSizedListToList` first and then get promoted too. Per-arg
dimensionality is preserved, so nested cases keep working with
`align_array_dimensions`.
## Are these changes tested?
Yes, added sqllogictests in `array_concat.slt` covering:
- `List` + `LargeList`
- `LargeList` + `List`
- `FixedSizeList` + `LargeList`
- Three-way mix `List`, `LargeList`, `List`
Each one also asserts `arrow_typeof(...) = LargeList(Int64)`.
## Are there any user-facing changes?
Queries that previously returned an internal cast error now return the
concatenated `LargeList` as expected. No API changes.1 parent c470bb1 commit e524f49
2 files changed
Lines changed: 47 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
| 321 | + | |
321 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
322 | 328 | | |
323 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
324 | 337 | | |
325 | 338 | | |
326 | 339 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
124 | 156 | | |
125 | 157 | | |
126 | 158 | | |
| |||
0 commit comments