You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SQL set operations ignore top-level ORDER BY and LIMIT #7729
A top-level ORDER BY or LIMIT following a SQL set operation is silently ignored. This can return rows in the wrong order or return more rows than requested.
To Reproduce
importdaftquery="SELECT 2 AS id UNION ALL SELECT 1 AS id ORDER BY id"print(daft.sql(query).to_pydict())
print(daft.sql(query+" LIMIT 1").to_pydict())
With Daft 0.7.26 using the native runner, the output is:
{'id': [2, 1]}
{'id': [2, 1]}
Expected behavior
The first query should return {'id': [1, 2]}; the second should return {'id': [1]}. The clauses apply to the result of the entire set operation.
Component(s)
Other (SQL planner)
Additional context
Reproduced with the official Daft 0.7.26 wheel, Python 3.12.13, and the native runner on Linux. PostgreSQL 16.16, MySQL 8.0.46, Spark SQL 3.5.1, DuckDB 2.0.0, SQLite 3.53.1, and Flink SQL 1.20.3 in batch mode return 1, 2 for the first query.
The same early return remains in the current SQL planner: the set-operation branch returns before the top-level clauses are planned.
Activity