Skip to content

Support empty array for array_union, array_intersect, and array_except #8181

Closed
@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

We cant deal with empty array for these three array function

Result

query ?
select array_union([], []);
----
NULL

query ?
select array_except([], []);
----
NULL

query error
select array_intersect([], []);
----
DataFusion error: Optimizer rule 'simplify_expressions' failed
caused by
Internal error: could not cast value to arrow_array::array::list_array::GenericListArray<i32>.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Expected

query ?
select array_union([], []);
----
[]

query ?
select array_except([], []);
----
[]

query error
select array_intersect([], []);
----
[]

Describe the solution you'd like

Able to deal with empty array

Describe alternatives you've considered

None

Additional context

IIRC empty array has been an issue for long, we can't differentiate it from null array, so I think this issue is not only for these three array functions. I had traced this issue before but ends up nothing and work on other tasks, if anyone is interesting, welcome to pick it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions