ODriscollBoys opened a new pull request, #26175: URL: https://github.com/apache/datafusion/pull/26175
## Which issue does this PR close? - Closes #24911. ## Rationale for this change `unnest` on a struct is only supported as the top-level select expression. Using it anywhere else, e.g. ```sql SELECT unnest(unnest(struct([1]))); SELECT unnest(struct(1))['c0']; ``` fails with `Internal error: Assertion failed: struct_allowed: ...` plus the "please file a bug report" footer. Whether this condition holds depends only on the shape of the user's query, so it is a planning error, not an internal invariant violation. #24912 proposed the same change and was closed together with a batch of other PRs rather than on its merits; this PR redoes it on current `main`. ## What changes are included in this PR? `RecursiveUnnestRewriter::transform` (`datafusion/sql/src/utils.rs`) returns `plan_err!` with the existing message instead of using `assert_or_internal_err!`. The error now reads: ``` Error during planning: unnest on struct can only be applied at the root level of select expression ``` ## What is the testing strategy for this PR? `unnest.slt` already had a case (`select arrow_typeof(unnest(column5)) from unnest_table`) that pinned the internal error text; it now expects the planning error. The two queries from the issue are added as new cases next to it. ## Are there any user-facing changes? The error for an unsupported nested struct `unnest` changes from an internal error to a planning error with the same message. No change for supported queries. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
