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
Got "LIMIT must not be negative" error as long as it is not a literal #9506
$ datafusion-cli --color
DataFusion CLI v36.0.0
❯ select * from '1.parquet' limit 1 + 1;
Error during planning: LIMIT must not be negative
❯
It should work as long as it can be evaluated without schema or data, here is how duckdb handles it:
$ duckdb
v0.10.0 20b1486d11
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D create table foo (id int);
D select * from foo limit 1 + 1;
┌────────┐
│ id │
│ int32 │
├────────┤
│ 0 rows │
└────────┘
To Reproduce
See above, the table (parquet file) should not matter.
changed the title [-]Got `LIMIT must not be negative` error as long as it is not a literal[/-][+]Got "LIMIT must not be negative" error as long as it is not a literal[/+]on Mar 8, 2024
So if DataFusion wants to follow DuckDB's behavior, then I guess we should evaluate that SQLExpr rather than simply converting it to DataFusion's Expr type.
Activity
[-]Got `LIMIT must not be negative` error as long as it is not a literal[/-][+]Got "LIMIT must not be negative" error as long as it is not a literal[/+]SteveLauC commentedon Mar 8, 2024
So if DataFusion wants to follow DuckDB's behavior, then I guess we should evaluate that
SQLExprrather than simply converting it to DataFusion'sExprtype.jonahgao commentedon Mar 11, 2024
I think ideally it should support any scalar expression.
In PostgreSQL, even functions and scalar subqueries are allowed.
SteveLauC commentedon Mar 11, 2024
Yeah, as long as it can be evaluated to a number, it should work.
alamb commentedon Mar 24, 2024
I think we could run the Expr simplifier / const folder on the limit value
I am not sure we can do so from within the planner itself 🤔
https://github.com/apache/arrow-datafusion/blob/1e4ddb6d86328cb6596bb50da9ccc654f19a83ea/datafusion/sql/src/query.rs#L249C1-L253C1
SteveLauC commentedon Aug 26, 2026
Yeah, scalar subquery is still not suported in DataFusion v55