Skip to content

unnest + field access of "list of struct" broken #12921

@crepererum

Description

@crepererum

Describe the bug

See reproducer.

To Reproduce

Use the following sqllogictest:

statement ok
CREATE TABLE lists_of_structs_table
AS VALUES 
    ('row1', [named_struct('a', 1, 'b', 2), named_struct('a', 2, 'b', 3)]),
    ('row2', [named_struct('a', 4, 'b', 5)])
;

query T?
select column1, unnest(column2) from lists_of_structs_table;
----
row1 {a: 1, b: 2}
row1 {a: 2, b: 3}
row2 {a: 4, b: 5}

# unnest + struct element access
query error DataFusion error: Schema error: No field named b. Valid fields are lists_of_structs_table.column1, lists_of_structs_table.column2.
select column1, unnest(column2)["b"] from lists_of_structs_table;

Expected behavior

Since unnest creates a struct column, I feel that this should work.

Additional context

Tested w/ 5391c98 .

Metadata

Metadata

Assignees

No one assigned

    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