Hi Andrei,
You can add a flag in SqlDialect and implement SybaseSqlDialect.

public class SqlDialect {
  private boolean fetchLast = true;
  ......
}

Then, you can control the unparse order according to your flag(fetchLast)
in dialect (SqlWriter.getDialect()) in SelectSqlOperator.

Best,
DonnyZone

Andrei Sereda <[email protected]> 于2019年6月19日周三 上午3:31写道:

> 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
>

Reply via email to