-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: expand unnest to accept arbitrary single array expression
#9342
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
Conversation
|
|
||
| query error DataFusion error: Error during planning: unnest\(\) can only be applied to array and structs and null | ||
| query error DataFusion error: Error during planning: unnest\(\) can only be applied to array and struct | ||
| select unnest(null); |
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.
This test shows that null is not supported, which conflicts with the error message.
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.
It is an error because unnest with null is not supported, but it should, so the error message contains null and struct.
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 add null checking and return not yet implemented error
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.
I misunderstood the intention of this error message. Fixed and thank you!
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 add null checking and return not yet implemented error
Done.
| } | ||
| }; | ||
| // Check argument type, array types are supported | ||
| match arg.get_type(schema)? { |
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 @jonahgao |
jayzhan211
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.
LGTM
|
❤️ |
Which issue does this PR close?
Found in #9315 (comment)
unnest(make_array(1,2))is supported, butunnest(range(1,3))is not supported.These are all supported in DuckDB.
Rationale for this change
If I understand correctly,
unnestshould support any expression with a return type of Array, not just themake_arrayfunction and column expressions.What changes are included in this PR?
The
unnestfunction can accept any array expression, which is ensured by checking the return type of the argument.Previously, it only supported the
make_arrayfunction and column expressions.Are these changes tested?
Yes. New tests and existing tests.
Are there any user-facing changes?
No