Hello everyone!
I suggest that for the Calcite SQL engine for "FETCH { FIRST | NEXT } [ count ]
{ ROW | ROWS } ONLY" [1], it is possible to specify not only a positive integer
literal, but also scalar expressions.
For example:
select * from PUBLIC.PERSON fetch first (10 + 1) rows only;
select * from PUBLIC.PERSON fetch first (10 + ?) rows only;
select * from PUBLIC.PERSON fetch first ((COALESCE(?, 10)) rows only;
This is not a part of the standard, but other vendors support such postgresql
[2], oracle [3], h2 [4] and mssql [5].
Thoughts, suggestions, objections?
[1] - https://calcite.incubator.apache.org/docs/reference.html
[2] - https://www.postgresql.org/docs/18/sql-select.html#SQL-LIMIT
[3] -
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/SELECT.html
[4] - https://h2database.com/html/commands.html#select
[5] -
https://learn.microsoft.com/ru-ru/sql/t-sql/queries/select-order-by-clause-transact-sql?view=sql-server-ver17#fetch--first--next---integer_constant--fetch_row_count_expression---row--rows--only