xiedeyantu opened a new pull request, #21259: URL: https://github.com/apache/datafusion/pull/21259
## Which issue does this PR close? - Closes #21258. ## Rationale for this change When `SELECT * EXCLUDE(...)` or `SELECT * EXCEPT(...)` excludes every column in the schema, DataFusion silently produces rows with zero columns instead of failing at planning time. This is confusing and inconsistent with DuckDB, which raises a clear `Binder Error: SELECT list is empty after resolving * expressions!` at planning time. ## What changes are included in this PR? - In `project_with_validation` (builder.rs), after expanding all `Wildcard` and `QualifiedWildcard` expressions, added a check: if any wildcard was present **and** the resulting projection list is empty, return a `plan_err!` with the message `SELECT list is empty after resolving * expressions, the wildcard expanded to zero columns`. - Updated select.slt to change all existing "zero-column wildcard" test cases (previously `statement ok`) to `statement error` asserting the new error message. Cases updated include bare `SELECT * EXCEPT(all_cols)`, with `LIMIT`, `WHERE`, `GROUP BY`, `JOIN`, and window functions. ## Are these changes tested? Yes. The existing SQL logic tests in select.slt are updated to assert the new planning error for all zero-column wildcard scenarios (`EXCLUDE` and `EXCEPT`, with various clauses). This covers: - `SELECT * EXCLUDE(a, b)` / `SELECT * EXCEPT(a, b, c, d)` on a plain scan - Combined with `LIMIT`, `WHERE`, `GROUP BY`, `JOIN`, and window functions - Qualified wildcards (`SELECT t.* EXCLUDE(...)`) ## Are there any user-facing changes? Yes. Queries that previously silently returned empty-column result sets via `SELECT * EXCLUDE(...)` or `SELECT * EXCEPT(...)` when all columns were excluded will now fail at planning time with: ``` DataFusion error: Error during planning: SELECT list is empty after resolving * expressions, the wildcard expanded to zero columns ``` -- 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]
