use of com.google.zetasql.resolvedast.ResolvedNodes.ResolvedOrderByScan in project beam by apache.
the class LimitOffsetScanToOrderByLimitConverter method convert.
@Override
public RelNode convert(ResolvedLimitOffsetScan zetaNode, List<RelNode> inputs) {
ResolvedOrderByScan inputOrderByScan = (ResolvedOrderByScan) zetaNode.getInputScan();
RelNode input = inputs.get(0);
RelCollation relCollation = getRelCollation(inputOrderByScan);
RexNode offset = zetaNode.getOffset() == null ? null : getExpressionConverter().convertRexNodeFromResolvedExpr(zetaNode.getOffset());
RexNode fetch = getExpressionConverter().convertRexNodeFromResolvedExpr(zetaNode.getLimit(), zetaNode.getColumnList(), input.getRowType().getFieldList(), ImmutableMap.of());
if (RexLiteral.isNullLiteral(offset) || RexLiteral.isNullLiteral(fetch)) {
throw new UnsupportedOperationException("Limit requires non-null count and offset");
}
RelNode sorted = LogicalSort.create(input, relCollation, offset, fetch);
return convertOrderByScanToLogicalScan(inputOrderByScan, sorted);
}
Aggregations