-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: unnest struct field with an alias failed with internal error #19698
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
Merged
+51
−4
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,20 @@ select unnest(struct(1,2,3)); | |
| ---- | ||
| 1 2 3 | ||
|
|
||
| ## Basic unnest expression in select struct with alias (alias is ignored for struct unnest) | ||
| query III | ||
| select unnest(struct(1,2,3)) as ignored_alias; | ||
| ---- | ||
| 1 2 3 | ||
|
|
||
| ## Verify schema output for struct unnest with alias (alias is ignored) | ||
| query TTT | ||
| describe select unnest(struct(1,2,3)) as ignored_alias; | ||
| ---- | ||
| __unnest_placeholder(struct(Int64(1),Int64(2),Int64(3))).c0 Int64 YES | ||
| __unnest_placeholder(struct(Int64(1),Int64(2),Int64(3))).c1 Int64 YES | ||
| __unnest_placeholder(struct(Int64(1),Int64(2),Int64(3))).c2 Int64 YES | ||
|
|
||
| ## Basic unnest list expression in from clause | ||
| query I | ||
| select * from unnest([1,2,3]); | ||
|
|
@@ -798,9 +812,21 @@ NULL 1 | |
| query error DataFusion error: Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "nested_unnest_table\.column1" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "UNNEST\(nested_unnest_table\.column1\)\[c0\]" appears in the SELECT clause satisfies this requirement | ||
| select unnest(column1) c1 from nested_unnest_table group by c1.c0; | ||
|
|
||
| # TODO: this query should work. see issue: https://github.com/apache/datafusion/issues/12794 | ||
| query error DataFusion error: Internal error: Assertion failed: struct_allowed: unnest on struct can only be applied at the root level of select expression | ||
| ## Unnest struct with alias - alias is ignored (same as DuckDB behavior) | ||
| ## See: https://github.com/apache/datafusion/issues/12794 | ||
| query TT? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise here, it would be great to test the schema output describe select unnest(column1) c1 from nested_unnest_table; |
||
| select unnest(column1) c1 from nested_unnest_table | ||
| ---- | ||
| a b {c0: c} | ||
| d e {c0: f} | ||
|
|
||
| ## Verify schema output for struct unnest with alias (alias is ignored) | ||
| query TTT | ||
| describe select unnest(column1) c1 from nested_unnest_table; | ||
| ---- | ||
| __unnest_placeholder(nested_unnest_table.column1).c0 Utf8 YES | ||
| __unnest_placeholder(nested_unnest_table.column1).c1 Utf8 YES | ||
| __unnest_placeholder(nested_unnest_table.column1).c2 Struct("c0": Utf8) YES | ||
|
|
||
| query II??I?? | ||
| select unnest(column5), * from unnest_table; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also please add a test for the output schema. Perhaps using
describe?Someting like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds good. Thanks for the feedback.