use of org.apache.flink.table.operations.SortQueryOperation in project flink by apache.
the class SortOperationFactory method createLimitWithFetch.
/**
* Creates a valid {@link SortQueryOperation} with fetch (possibly merged into a preceding
* {@link SortQueryOperation}).
*
* @param fetch fetch to limit
* @param child relational expression on top of which to apply the sort operation
* @param postResolverFactory factory for creating resolved expressions
* @return valid sort operation with applied offset
*/
QueryOperation createLimitWithFetch(int fetch, QueryOperation child, PostResolverFactory postResolverFactory) {
SortQueryOperation previousSort = validateAndGetChildSort(child, postResolverFactory);
if (fetch < 0) {
throw new ValidationException("Fetch should be greater or equal 0");
}
int offset = Math.max(previousSort.getOffset(), 0);
return new SortQueryOperation(previousSort.getOrder(), previousSort.getChild(), offset, fetch);
}
Aggregations