Search in sources :

Example 1 with ResolvedOrderByScan

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);
}
Also used : RelCollation(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation) RelNode(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode) ResolvedOrderByScan(com.google.zetasql.resolvedast.ResolvedNodes.ResolvedOrderByScan) RexNode(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)

Aggregations

ResolvedOrderByScan (com.google.zetasql.resolvedast.ResolvedNodes.ResolvedOrderByScan)1 RelCollation (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation)1 RelNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode)1 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)1