final RexBuilder rexBuilder = sort.getCluster().getRexBuilder(); final RelMetadataQuery mq = call.getMetadataQuery(); final RelOptPredicateList predicates = mq.getPulledUpPredicates(sort.getInput());
final RexBuilder rexBuilder = sort.getCluster().getRexBuilder(); final RelMetadataQuery mq = RelMetadataQuery.instance(); final RelOptPredicateList predicates = mq.getPulledUpPredicates(sort.getInput());
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } RelTraitSet origTraitSet = sort.getTraitSet(); RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify(); RelNode input = sort.getInput(); if (!sort.getCollation().getFieldCollations().isEmpty()) { // Create a sort with the same sort key, but no offset or fetch. input = sort.copy(sort.getTraitSet(), input, sort.getCollation(), null, null); } RelNode x = convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)); call.transformTo(new OLAPLimitRel(sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); }
final RexBuilder rexBuilder = sort.getCluster().getRexBuilder(); final List<RelFieldCollation> collationsList = sort.getCollation().getFieldCollations().stream()
final RexBuilder rexBuilder = sort.getCluster().getRexBuilder(); final List<RelFieldCollation> collationsList = sort.getCollation().getFieldCollations().stream()
/** * Converts a {@code Sort} into a {@code JdbcSort}. * * @param sort Sort operator to convert * @param convertInputTraits Whether to convert input to {@code sort}'s * JDBC convention * @return A new JdbcSort */ public RelNode convert(Sort sort, boolean convertInputTraits) { final RelTraitSet traitSet = sort.getTraitSet().replace(out); final RelNode input; if (convertInputTraits) { input = convert(sort.getInput(), traitSet); } else { input = sort.getInput(); } return new JdbcSort(sort.getCluster(), traitSet, input, sort.getCollation(), sort.offset, sort.fetch); } }
/** * Converts a {@code Sort} into a {@code JdbcSort}. * * @param sort Sort operator to convert * @param convertInputTraits Whether to convert input to {@code sort}'s * JDBC convention * @return A new JdbcSort */ public RelNode convert(Sort sort, boolean convertInputTraits) { final RelTraitSet traitSet = sort.getTraitSet().replace(out); final RelNode input; if (convertInputTraits) { input = convert(sort.getInput(), traitSet); } else { input = sort.getInput(); } return new JdbcSort(sort.getCluster(), traitSet, input, sort.getCollation(), sort.offset, sort.fetch); } }
@Override public RelNode convert(RelNode r) { Sort rel = (Sort) r; RelTraitSet traits = rel.getInput().getTraitSet().replace(Prel.DRILL_PHYSICAL); return new SortPrel(rel.getCluster(), traits.plus(rel.getCollation()), convert(rel.getInput(), traits.simplify()), rel.getCollation()); } }
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); final RelNode input = sort.getInput(); final RelTraitSet traits = sort.getTraitSet().plus(Rel.LOGICAL); final RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify()); call.transformTo(new SortRel(sort.getCluster(), traits, convertedInput, sort.getCollation())); } }
@Override public void onMatch(RelOptRuleCall call) { final Sort incomingSort = call.rel(0); final RelTraitSet incomingTraits = incomingSort.getTraitSet(); RelNode input = incomingSort.getInput(); // if the calcite sort rel includes a collation and a limit, we need to create a copy the sort rel that excludes the // limit information. if (!incomingSort.getCollation().getFieldCollations().isEmpty()) { input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null); } RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify()); call.transformTo(new LimitRel(incomingSort.getCluster(), convertedInput.getTraitSet().plus(Rel.LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch)); }
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); final RelNode input = sort.getInput(); final RelTraitSet traits = sort.getTraitSet().plus(DrillRel.DRILL_LOGICAL); final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify()); call.transformTo(new DrillSortRel(sort.getCluster(), traits, convertedInput, sort.getCollation())); } }
@Override public void onMatch(RelOptRuleCall call) { final Sort incomingSort = call.rel(0); final RelTraitSet incomingTraits = incomingSort.getTraitSet(); RelNode input = incomingSort.getInput(); // if the Optiq sort rel includes a collation and a limit, we need to create a copy the sort rel that excludes the // limit information. if (!incomingSort.getCollation().getFieldCollations().isEmpty()) { input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null); } RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify()); call.transformTo(new DrillLimitRel( incomingSort.getCluster(), convertedInput.getTraitSet().plus(DrillRel.DRILL_LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch)); }
@Override public RelNode convert(RelNode r) { Sort rel = (Sort) r; return new SortPrel(rel.getCluster(), rel.getInput().getTraitSet().replace(Prel.PHYSICAL).plus(rel.getCollation()), convert(rel.getInput(), rel.getInput().getTraitSet().replace(Prel.PHYSICAL).simplify()), rel.getCollation()); } }
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } RelTraitSet origTraitSet = sort.getTraitSet(); RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify(); RelNode input = sort.getInput(); if (!sort.getCollation().getFieldCollations().isEmpty()) { // Create a sort with the same sort key, but no offset or fetch. input = sort.copy(sort.getTraitSet(), input, sort.getCollation(), null, null); } RelNode x = convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)); call.transformTo(new OLAPLimitRel(sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); }
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); RelNode input = sort.getInput(); if (!sort.getCollation().getFieldCollations().isEmpty()) { // Create a sort with the same sort key, but no offset or fetch. input = sort.copy( sort.getTraitSet(), input, sort.getCollation(), null, null); } RelNode x = convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)); call.transformTo( new EnumerableLimit( sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); } }
@Override public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); RelNode input = sort.getInput(); if (!sort.getCollation().getFieldCollations().isEmpty()) { // Create a sort with the same sort key, but no offset or fetch. input = sort.copy( sort.getTraitSet(), input, sort.getCollation(), null, null); } RelNode x = convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)); call.transformTo( new EnumerableLimit( sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); } }