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