-
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
base: main
Are you sure you want to change the base?
Conversation
alamb
left a comment
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.
Thanks @kumarUjjawal -- this looks really nice. I have a suggestion for another test too. Let me know what you think
|
|
||
| ## 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; |
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
describe select unnest(struct(1,2,3));
+-------------------------------------------------------------+-----------+-------------+
| column_name | data_type | is_nullable |
+-------------------------------------------------------------+-----------+-------------+
| __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 |
+-------------------------------------------------------------+-----------+-------------+
3 row(s) fetched.
Elapsed 0.007 seconds.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.
| 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? |
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.
Likewise here, it would be great to test the schema output
describe select unnest(column1) c1 from nested_unnest_table;
alamb
left a comment
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.
Thank you
Which issue does this PR close?
Rationale for this change
Unnesting with an alias resulted in an internal error it should just be ignored.
What changes are included in this PR?
transformed_root_exprsto only apply to actual struct types (which return multiple expressions)Are these changes tested?
Yes
Are there any user-facing changes?