Skip to content

make_array null handling with nested version #7136

Closed
@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

Follow up on #6900. Implement array() nested version.
It seems calling array() for list return flattened list according to the comment

https://github.com/apache/arrow-datafusion/blob/2cf5f5b5bb824598de185d64c541c52c930728cf/datafusion/physical-expr/src/array_expressions.rs#L243-L254

However, I think make_array should wrap the elements into array, the expected behavior
make_array([A,X], []) -> [[A,X], []],
make_array([null, Y], [Q,R,S]) -> [[null,Y],[Q,R,S]] and
make_array([C,Z], null) -> [[C,Z], null]

Main branch:

query ?
select make_array(['A','X'], []);
----
[[A, X], ]

query ?
select make_array(make_array(null,'Y'), make_array('Q','R','S'));
----
[[, Y], [Q, R, S]]

query error DataFusion error: Optimizer rule 'simplify_expressions' failed
caused by
Internal error: failed to downcast\. 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
select make_array(['C','Z'], null);

As a result, only the third case fails, the first case is acceptable but should we expected [[A, X], []] to differentiate with null can also be discussed

Describe the solution you'd like

Fix the third case and update the comments.
Optional: Expect the first case to return [[A, X], []]

Describe alternatives you've considered

No response

Additional context

No response

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