geoHeil opened a new issue, #27426: URL: https://github.com/apache/datafusion/issues/27426
The unparser can emit an empty SELECT list for a filtered count and leave a base-table qualifier outside its scope for a projected LIMIT. Observed native failures include PostgreSQL rejecting an out-of-scope qualifier, and DuckDB, ClickHouse and BigQuery rejecting an empty SELECT list. These came from optimized plans using the 55.1.0 SQL frontend with the existing literal Limit/Sort window patch. Current main retains both relevant code paths; these exact native runs have not been repeated against main. For a filtered count, the generated shape was: ```sql SELECT count(1) AS n FROM (SELECT FROM t WHERE (t.value = 0.0)) ``` BigQuery reports `SELECT list must not be empty`; DuckDB reports `SELECT clause without selection list`. For a projected filtered limit, PostgreSQL received: ```sql SELECT CAST(t.id AS BIGINT) AS key FROM (SELECT t.id FROM t WHERE (t.id = 1002) LIMIT 2 OFFSET 0) AS derived_limit ``` PostgreSQL reports `missing FROM-clause entry for table "t"`. The base table is inside the derived table, so the outer qualifier is out of scope. Two narrow candidate repairs in `datafusion/sql/src/unparser/plan.rs`: - In `reconstruct_select_statement`, use the existing `empty_projection_fallback()` for an empty explicit projection. This preserves PostgreSQL's declared support for empty SELECT lists while emitting a dummy literal for other dialects. - In the Projection arm, reuse the existing Sort/Limit absorption for a complete chain ending in Filter nodes over a TableScan without a pushed fetch. Keep the filters in place and emit the projected expression, WHERE and LIMIT in one SELECT. This avoids crossing Projection, Join, Distinct, Window or alias boundaries. It does not repair the separate TableScan.fetch expansion path. A native regression corpus already demonstrates the failures above. The candidate repairs still require a green native run; no result is claimed for current main or the proposed repair. -- 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]
