Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnest function doesn't work as expected with additional columns #9349

Closed
Omega359 opened this issue Feb 26, 2024 · 8 comments · Fixed by #9400
Closed

Unnest function doesn't work as expected with additional columns #9349

Omega359 opened this issue Feb 26, 2024 · 8 comments · Fixed by #9400
Assignees
Labels
bug Something isn't working

Comments

@Omega359
Copy link
Contributor

Describe the bug

Note that this isn't pertaining to unnest(column1, column2) functionality but rather that what should either work or explicitly fail (because it's not supported) is returning incorrect results.

To Reproduce

I used the unnest.slt test and added the following:

query
select unnest(column1), column3 from unnest_table;

If you run

cargo test --test sqllogictests -- unnest --complete

this will complete to the following

query I
select unnest(column1), column3 from unnest_table;
----
1
2
3
4
5
6
12

That result is wrong as it's missing column3 data.

Expected behavior

Either an error be returned or the result returns something like

1, 1
2, 1
3, 1
4, 2
5, 2
6, 3
12, null

Additional context

No response

@Omega359 Omega359 added the bug Something isn't working label Feb 26, 2024
@Omega359
Copy link
Contributor Author

fyi @jonahgao

@alamb
Copy link
Contributor

alamb commented Feb 26, 2024

FYI @jayzhan211

@Omega359
Copy link
Contributor Author

Note that this fails (as expected right now) though I'm not certain if it's related to this issue or just something else :

query error DataFusion error: This feature is not implemented: Unsupported ast node UNNEST \{ alias: Some\(TableAlias \{ name: Ident \{ value: "unnested_col_1", quote_style: Some\('\\''\) \}, columns: \[\] \}\), array_exprs: \[Identifier\(Ident \{ value: "column1", quote_style: None \}\)\], with_offset: false, with_offset_alias: None \} in create_relation
SELECT column3, unnested_col_1 FROM unnest_table, unnest(column1) AS 'unnested_col_1';

@jonahgao
Copy link
Member

Note that this fails (as expected right now) though I'm not certain if it's related to this issue or just something else :

query error DataFusion error: This feature is not implemented: Unsupported ast node UNNEST \{ alias: Some\(TableAlias \{ name: Ident \{ value: "unnested_col_1", quote_style: Some\('\\''\) \}, columns: \[\] \}\), array_exprs: \[Identifier\(Ident \{ value: "column1", quote_style: None \}\)\], with_offset: false, with_offset_alias: None \} in create_relation
SELECT column3, unnested_col_1 FROM unnest_table, unnest(column1) AS 'unnested_col_1';

This one is related to issue #9324. I am working on supporting it.

@jayzhan211
Copy link
Contributor

jayzhan211 commented Feb 26, 2024

This is not yet supported. Currently, only the simplest feature is supported. Known issue from #6555, and I tried it once in #6796. Things getting complex for multiple columns, since we need to somehow join them

@jayzhan211
Copy link
Contributor

If I remember correctly, select * from table in #9324 and select unnest() from table in this issue are quite different.
I think we can work on them separately, also it might be easier to start with a single column than a multi-column.

@jonahgao
Copy link
Member

I would like to give this a try, as I have learned a bit about UNNEST recently.

@jonahgao
Copy link
Member

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants