case SORT: final MutableSort sort = (MutableSort) node; return LogicalSort.create(fromMutable(sort.input), sort.collation, sort.offset, sort.fetch); case UNION:
@Override public RelNode visit(LogicalSort sort) { final RelNode input = sort.getInput().accept(this); return new LogicalSort( cluster, copyOf(sort.getTraitSet()), input, sort.getCollation(), copyOf(sort.offset), copyOf(sort.fetch) ); }
@Override public Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { return new LogicalSort(getCluster(), traitSet, newInput, newCollation, offset, fetch); }
rootSort = LogicalSort.create(rootPrj, newCollation, rootSort.offset, rootSort.fetch); root = new RelRoot(rootSort == null ? rootPrj : rootSort, validRowType, root.kind, projFields, rootSort == null ? root.collation : rootSort.getCollation());
/** * Creates a LogicalSort. * * @param input Input relational expression * @param collation array of sort specifications * @param offset Expression for number of rows to discard before returning * first row * @param fetch Expression for number of rows to fetch */ public static LogicalSort create(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { RelOptCluster cluster = input.getCluster(); collation = RelCollationTraitDef.INSTANCE.canonize(collation); RelTraitSet traitSet = input.getTraitSet().replace(Convention.NONE).replace(collation); return new LogicalSort(cluster, traitSet, input, collation, offset, fetch); }
@Override public RelNode visit(LogicalSort sort) { return sort.getInput().accept(this); }
/** * Creates a LogicalSort. * * @param input Input relational expression * @param collation array of sort specifications * @param offset Expression for number of rows to discard before returning * first row * @param fetch Expression for number of rows to fetch */ public static LogicalSort create(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { RelOptCluster cluster = input.getCluster(); collation = RelCollationTraitDef.INSTANCE.canonize(collation); RelTraitSet traitSet = input.getTraitSet().replace(Convention.NONE).replace(collation); return new LogicalSort(cluster, traitSet, input, collation, offset, fetch); }
public RelNode createSort(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { return LogicalSort.create(input, collation, offset, fetch); }
@Override public Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { return new LogicalSort(getCluster(), traitSet, newInput, newCollation, offset, fetch); }
public RelNode createSort(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { return LogicalSort.create(input, collation, offset, fetch); }
private static RelNode createEmptyEmptyRelHelper(SingleRel input) { return LogicalSort.create(input.getInput(), RelCollations.EMPTY, input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)), input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0))); } }
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { // An empty sort doesn't make sense. return null; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Sort sort = LogicalSort.create(rel, toCollation, null, null); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Sort sort = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(sort.getInput()); final LogicalSort newSort = LogicalSort.create(newDelta, sort.collation, sort.offset, sort.fetch); call.transformTo(newSort); } }
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Sort sort = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(sort.getInput()); final LogicalSort newSort = LogicalSort.create(newDelta, sort.collation, sort.offset, sort.fetch); call.transformTo(newSort); } }
LogicalSort.create(bb.root, collation, offset == null ? null : convertExpression(offset), fetch == null ? null : convertExpression(fetch)),
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { // An empty sort doesn't make sense. return null; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Sort sort = LogicalSort.create(rel, toCollation, null, null); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
LogicalSort.create(bb.root, collation, offset == null ? null : convertExpression(offset), fetch == null ? null : convertExpression(fetch)),
LogicalSort.create(bb.root, collation, offset == null ? null : convertExpression(offset), fetch == null ? null : convertExpression(fetch)),
LogicalSort.create(bb.root, collation, offset == null ? null : convertExpression(offset), fetch == null ? null : convertExpression(fetch)),
LogicalSort.create(newInput, newCollation, rel.offset, rel.fetch);