Hi Andrei It may not be in scope to support but to note, Sybase (certainly IQ, but likely ASE?) does not support the limit / top in nested / sub queries. You need to simulate it via adding an olap row number column and performing a filter on that (and then dropping the row number column from the final results).
https://www.jooq.org/doc/3.11/manual/sql-building/sql-statements/select-statement/limit-clause/#N468DE Andrew On Tue, 18 Jun 2019, 20:31 Andrei Sereda, <[email protected]> wrote: > Hello, > > I'm trying to add limit / offset support to Sybase (v11) dialect. > Unfortunately sybase syntax is not standard [1] (before v12 at least) > compared to other dialects. > > Example > ```sql > select * from table LIMIT 10 OFFSET 5 -- standard SQL > select TOP 10 START AT 5 * from table -- Sybase > ``` > > SqlSelectOperator [2] has unparsing of LIMIT / OFFSET at the end. Which > makes it difficult to inject custom SqlNode(s). > > What is the recommended way to deal with this? > > 1) Custom SqlSelectOperator for Sybase > 2) Splitting SqlSelectOperator.unparse() to be more customizable > 3) Adding special SqlNode(s) to SqlSelect.selectList > 4) Adding special SqlNode(s) to SqlSelect.keywordList > > Thanks, > Andrei. > > [1] http://dcx.sybase.com/1100/en/dbusage_en11/first-order-formatting.html > [2] > > https://github.com/apache/calcite/blob/9721283bd0ce46a337f51a3691585cca8003e399/core/src/main/java/org/apache/calcite/sql/SqlSelectOperator.java#L133 >
