[ 
https://issues.apache.org/jira/browse/CALCITE-1265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15308239#comment-15308239
 ] 

Julian Hyde commented on CALCITE-1265:
--------------------------------------

Before you push down offset/fetch you need to be sure that that particular 
dialect of SQL supports it, and what is the syntax. I suppose by default you 
can assume that the database supports SQL:2008 {{FETCH FIRST}} syntax. But 
[wikipedia|https://en.wikipedia.org/wiki/Select_%28SQL%29#Result_limits] lists 
many other variants.

FWIW, here is syntax as of SQL:2014:

{code}
<query primary> ::=
    <simple table>
  | <left paren> <query expression body>
      [ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
      <right paren>
<order by clause> ::=
  ORDER BY <sort specification list>
<result offset clause> ::=
  OFFSET <offset row count> { ROW | ROWS }
<fetch first clause> ::=
  FETCH { FIRST | NEXT } [ <fetch first quantity> ] { ROW | ROWS } { ONLY | 
WITH TIES }
<fetch first quantity> ::=
    <fetch first row count>
  | <fetch first percentage>
<offset row count> ::=
  <simple value specification>
<fetch first row count> ::=
  <simple value specification>
<fetch first percentage> ::=
  <simple value specification> PERCENT
{code}

For Calcite's purposes, {{OFFSET offset ROWS FETCH FIRST limit ROWS ONLY}} will 
be sufficient.

> Implement offset/fetch in JdbcSort
> ----------------------------------
>
>                 Key: CALCITE-1265
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1265
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jordan Halterman
>            Assignee: Julian Hyde
>             Fix For: 1.8.0
>
>
> In {{JdbcSort}}, support for offset/fetch is currently disabled. This seems 
> like it may have simply been a result of a lack of support in 
> {{RelToSqlConverter}} at the time that commit was made. Since 
> {{RelToSqlConverter}} got support for offset/fetch in sorts recently, this 
> should be implemented in {{JdbcSort}} as well.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to