Nested `unnest` of a struct reports an internal error ("Assertion failed: struct_allowed") instead of a planning error
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start in datafusion/sql/src/utils.rs at RecursiveUnnestRewriter::transform, where struct_allowed currently produces the internal error. Review the unnest.slt coverage, including the arrow_typeof(unnest(column5)) case, and run the relevant SQL tests. Done means nested struct unnest expressions report the stated planning error instead of an internal error.
Written by the indexing model from the issue text.
Description
Describe the bug
unnest on a struct is only supported as the top-level select expression. Using it anywhere else hits assert_or_internal_err!(struct_allowed, ...) in RecursiveUnnestRewriter::transform (datafusion/sql/src/utils.rs), so the user gets an internal error that asks them to file a bug, even though the condition is entirely determined by the shape of their query.
To Reproduce
SELECT unnest(unnest(struct([1])));
SELECT unnest(struct(1))['c0'];
Internal error: Assertion failed: struct_allowed: unnest on struct can only be applied at the root level of select expression.
This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
unnest.slt even has a test (select arrow_typeof(unnest(column5)) from unnest_table) that pins this internal-error text.
Expected behavior
Error during planning: unnest on struct can only be applied at the root level of select expression
Additional context
Found while running a corpus of unusual unnest expressions against datafusion-cli.
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 354
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/datafusion#25266 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/datafusion#25213 · 1 comment ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/datafusion#25168 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/datafusion#24998 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion#24913 ·
All issues in apache/datafusion
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100