Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Sep 12, 2025

Which issue does this PR close?

Rationale for this change

We fixed a bug found in testing DataFusion 50, so let's backport the change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

* Add failing test

* Fix regression in SELECT FROM syntax with WHERE clause

When using 'SELECT FROM table WHERE condition', the query should create
an empty projection (no columns) while still filtering rows. This was
broken by PR apache#17295 which added FROM-first syntax support.

The issue was that both 'FROM table' and 'SELECT FROM table' resulted
in empty projection lists, making them indistinguishable. The fix checks
for the presence of a WHERE clause to differentiate:
- 'FROM table' (no WHERE) -> add wildcard projection (all columns)
- 'SELECT FROM table WHERE ...' -> keep empty projection

Also updates the test expectation to correctly show the empty Projection
node in the query plan.

Fixes apache#17513

* Revert

* Fix regression: SELECT FROM syntax should return empty projection

Removes automatic wildcard projection for empty projections, fixing
the regression where `SELECT FROM table` incorrectly returned all
columns instead of empty projection.

Note: This temporarily breaks FROM-first syntax. A proper fix would
require distinguishing between `FROM table` and `SELECT FROM table`
at the parser level.

Fixes apache#17513

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* add a better regression test

* remove comment

* fmt

* Update datafusion/sqllogictest/test_files/projection.slt

Co-authored-by: Oleks V <comphead@users.noreply.github.com>

* Update datafusion/core/tests/sql/select.rs

Co-authored-by: Oleks V <comphead@users.noreply.github.com>

* revert docs

* fmt

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Oleks V <comphead@users.noreply.github.com>
@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Sep 12, 2025
@xudong963 xudong963 merged commit 10343c1 into apache:branch-50 Sep 13, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate documentation Improvements or additions to documentation sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants