Skip to content

array_sort fails if input batch is empty #10772

@kawadakk

Description

@kawadakk

Describe the bug

The array_sort SQL function produces an error concat requires input of at least one array if an empty batch (a batch containing zero lists) is provided as input.

To Reproduce

Add the following to datafusion/sqllogictest/test_files/array.slt:

query ?
select array_sort([sum(b)]) from values where a > 100 group by b;
----

This produces:

$ cargo test --test sqllogictests array.slt
...
Running "array.slt"
External error: query failed: DataFusion error: Arrow error: Compute error: concat requires input of at least one array
[SQL] select array_sort([sum(b)]) from values where a > 100 group by b;
at test_files/array.slt:2009

Error: Execution("1 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test sqllogictests`
...

Expected behavior

Successful test execution

Additional context

Can be reproduced in DataFusion v38 and main (59bfe77)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions