Commit bc2b36c
authored
fix:
## Which issue does this PR close?
- Closes apache#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
```SELECT * EXCLUDE(...) silently returns empty rows when all columns are excluded (apache#21259)1 parent f3e8291 commit bc2b36c
2 files changed
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1931 | 1931 | | |
1932 | 1932 | | |
1933 | 1933 | | |
| 1934 | + | |
1934 | 1935 | | |
1935 | 1936 | | |
1936 | 1937 | | |
1937 | 1938 | | |
| 1939 | + | |
1938 | 1940 | | |
1939 | 1941 | | |
1940 | 1942 | | |
| |||
1955 | 1957 | | |
1956 | 1958 | | |
1957 | 1959 | | |
| 1960 | + | |
1958 | 1961 | | |
1959 | 1962 | | |
1960 | 1963 | | |
| |||
1984 | 1987 | | |
1985 | 1988 | | |
1986 | 1989 | | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
1987 | 1996 | | |
1988 | 1997 | | |
1989 | 1998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1318 | 1318 | | |
1319 | 1319 | | |
1320 | 1320 | | |
1321 | | - | |
1322 | | - | |
| 1321 | + | |
| 1322 | + | |
1323 | 1323 | | |
1324 | 1324 | | |
1325 | 1325 | | |
1326 | | - | |
1327 | | - | |
| 1326 | + | |
| 1327 | + | |
1328 | 1328 | | |
1329 | 1329 | | |
1330 | 1330 | | |
1331 | 1331 | | |
1332 | | - | |
1333 | | - | |
| 1332 | + | |
| 1333 | + | |
1334 | 1334 | | |
1335 | 1335 | | |
1336 | 1336 | | |
1337 | 1337 | | |
1338 | | - | |
1339 | | - | |
| 1338 | + | |
| 1339 | + | |
1340 | 1340 | | |
1341 | 1341 | | |
1342 | 1342 | | |
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
1355 | | - | |
1356 | | - | |
| 1355 | + | |
| 1356 | + | |
1357 | 1357 | | |
1358 | 1358 | | |
1359 | 1359 | | |
1360 | 1360 | | |
1361 | 1361 | | |
1362 | | - | |
1363 | | - | |
| 1362 | + | |
| 1363 | + | |
1364 | 1364 | | |
1365 | 1365 | | |
1366 | 1366 | | |
| |||
1369 | 1369 | | |
1370 | 1370 | | |
1371 | 1371 | | |
1372 | | - | |
1373 | | - | |
| 1372 | + | |
| 1373 | + | |
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
| |||
0 commit comments