fix: SELECT * EXCLUDE(...) silently returns empty rows when all columns are excluded#21259
Open
xiedeyantu wants to merge 3 commits intoapache:mainfrom
Open
fix: SELECT * EXCLUDE(...) silently returns empty rows when all columns are excluded#21259xiedeyantu wants to merge 3 commits intoapache:mainfrom
SELECT * EXCLUDE(...) silently returns empty rows when all columns are excluded#21259xiedeyantu wants to merge 3 commits intoapache:mainfrom
Conversation
…umns are excluded
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?
SELECT * EXCLUDE(...)silently returns empty rows when all columns are excluded #21258.Rationale for this change
When
SELECT * EXCLUDE(...)orSELECT * 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 clearBinder Error: SELECT list is empty after resolving * expressions!at planning time.What changes are included in this PR?
project_with_validation(builder.rs), after expanding allWildcardandQualifiedWildcardexpressions, added a check: if any wildcard was present and the resulting projection list is empty, return aplan_err!with the messageSELECT list is empty after resolving * expressions, the wildcard expanded to zero columns.statement ok) tostatement errorasserting the new error message. Cases updated include bareSELECT * EXCEPT(all_cols), withLIMIT,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 (
EXCLUDEandEXCEPT, with various clauses). This covers:SELECT * EXCLUDE(a, b)/SELECT * EXCEPT(a, b, c, d)on a plain scanLIMIT,WHERE,GROUP BY,JOIN, and window functionsSELECT t.* EXCLUDE(...))Are there any user-facing changes?
Yes. Queries that previously silently returned empty-column result sets via
SELECT * EXCLUDE(...)orSELECT * EXCEPT(...)when all columns were excluded will now fail at planning time with: