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

ASF GitHub Bot commented on FLINK-7821:
---------------------------------------

Github user xccui commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4813#discussion_r146423134
  
    --- Diff: docs/dev/table/tableApi.md ---
    @@ -1031,19 +1034,22 @@ val result = in.orderBy('a.asc);
     
         <tr>
           <td>
    -        <strong>Limit</strong><br>
    +        <strong>Offset &amp; Fetch</strong><br>
             <span class="label label-primary">Batch</span>
           </td>
           <td>
    -        <p>Similar to a SQL LIMIT clause. Limits a sorted result to a 
specified number of records from an offset position. Limit is technically part 
of the Order By operator and thus must be preceded by it.</p>
    +        <p>Similar to the SQL OFFSET and FETCH clauses. Offset and Fetch 
limit the number of records returned from a sorted result. Offset and Fetch are 
technically part of the Order By operator and thus must be preceded by it.</p>
     {% highlight scala %}
    -val in = ds.toTable(tableEnv, 'a, 'b, 'c);
    -val result = in.orderBy('a.asc).limit(3); // returns unlimited number of 
records beginning with the 4th record
    -{% endhighlight %}
    -or
    -{% highlight scala %}
    -val in = ds.toTable(tableEnv, 'a, 'b, 'c);
    -val result = in.orderBy('a.asc).limit(3, 5); // returns 5 records 
beginning with the 4th record
    +val in = ds.toTable(tableEnv, 'a, 'b, 'c)
    +
    +// returns the first 5 records from the sorted result
    +val result1: Table = in.orderBy('a.asc).fetch(5)
    +
    +// returns all records beginning with the 4th record from the sorted result
    +val result2: Table = in.orderBy('a.asc).offset(3)
    +
    +// returns the first 5 records beginning with the 10th record from the 
sorted result
    --- End diff --
    
    Should be 11th?


> Replace Table.limit() by Table.fetch() and Table.offset()
> ---------------------------------------------------------
>
>                 Key: FLINK-7821
>                 URL: https://issues.apache.org/jira/browse/FLINK-7821
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table API & SQL
>    Affects Versions: 1.4.0
>            Reporter: Fabian Hueske
>            Assignee: Fabian Hueske
>            Priority: Minor
>
> The Table API method limit() exists in two variants:
> - {{limit(offset)}} returns all but the first {{offset}} records.
> - {{limit(offset, fetch)}} returns {{fetch}} records starting from the 
> {{offset}}'s record.
> Especially, the behavior of {{limit(offset)}} is confusing because one would 
> rather expect a behavior of returning the {{offset}} first records instead of 
> all but the {{offset}} first records.
> Moreover, the only way to return the first {{x}} records is to specify a 
> {{0}} offset as {{limit(0, x)}}.
> I propose to deprecate and replace both {{limit()}} variants by two new 
> methods {{Table.offset(offset)}} and {{Table.fetch(fetch)}} that can be 
> combined as follows:
> {code}
> table.orderBy(...).fetch(x)
> table.orderBy(...).offset(x)
> table.orderBy(...).offset(x).fetch(y)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to