feat: expand unnest to accept arbitrary single array expression#9342
Merged
jayzhan211 merged 3 commits intoapache:mainfrom Feb 26, 2024
Merged
feat: expand unnest to accept arbitrary single array expression#9342jayzhan211 merged 3 commits intoapache:mainfrom
unnest to accept arbitrary single array expression#9342jayzhan211 merged 3 commits intoapache:mainfrom
Conversation
jonahgao
commented
Feb 26, 2024
|
|
||
| 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); |
Member
Author
There was a problem hiding this comment.
This test shows that null is not supported, which conflicts with the error message.
Contributor
There was a problem hiding this comment.
It is an error because unnest with null is not supported, but it should, so the error message contains null and struct.
Contributor
There was a problem hiding this comment.
Can you also add null checking and return not yet implemented error
Member
Author
There was a problem hiding this comment.
I misunderstood the intention of this error message. Fixed and thank you!
Member
Author
There was a problem hiding this comment.
Can you also add null checking and return not yet implemented error
Done.
jayzhan211
reviewed
Feb 26, 2024
| } | ||
| }; | ||
| // Check argument type, array types are supported | ||
| match arg.get_type(schema)? { |
Contributor
|
Thanks @jonahgao |
Contributor
|
❤️ |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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