adriangb opened a new pull request, #17520:
URL: https://github.com/apache/datafusion/pull/17520

   ## Summary
   - Fixes #17513 
   - Fixes regression introduced by #17295 where `SELECT FROM table WHERE 
condition` incorrectly returned all columns instead of empty projection
   
   ## Problem
   PR #17295 added support for FROM-first syntax (e.g., `FROM table` without 
SELECT). However, it couldn't distinguish between:
   - `FROM table` - should select all columns (FROM-first syntax)
   - `SELECT FROM table WHERE ...` - should select no columns (empty projection)
   
   Both cases resulted in empty projection lists in the parser, making them 
indistinguishable.
   
   ## Solution
   The fix checks for the presence of a WHERE clause to differentiate:
   - Empty projection + no WHERE clause = FROM-first syntax → add wildcard 
projection
   - Empty projection + WHERE clause = SELECT FROM syntax → keep empty 
projection
   
   This ensures:
   - `FROM table` returns all columns (expected FROM-first behavior)
   - `SELECT FROM table WHERE condition` returns empty columns but correct row 
count
   - The optimizer still pushes down column requirements to TableScan for 
efficiency
   
   ## Test Changes
   Updated the test expectation in `projection.slt` to correctly show that 
`SELECT FROM table WHERE ...` produces an empty Projection node in the logical 
plan, while the TableScan still only projects the necessary columns.
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   Co-Authored-By: Claude <nore...@anthropic.com>


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to