public RelNode align(Sort rel, List<RelFieldCollation> collations) { final RelNode child = dispatchAlign(rel.getInput(), rel.collation.getFieldCollations()); return rel.copy(rel.getTraitSet(), ImmutableList.of(child)); }
public RelNode align(Sort rel, List<RelFieldCollation> collations) { final RelNode child = dispatchAlign(rel.getInput(), rel.collation.getFieldCollations()); return rel.copy(rel.getTraitSet(), ImmutableList.of(child)); }
final Sort combined = first.copy( first.getTraitSet(), first.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)); }
public abstract Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch);
public abstract Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch);
@Override public final Sort copy(RelTraitSet traitSet, List<RelNode> inputs) { return copy(traitSet, sole(inputs), collation, offset, fetch); }
@Override public final Sort copy(RelTraitSet traitSet, List<RelNode> inputs) { return copy(traitSet, sole(inputs), collation, offset, fetch); }
public RelNode accept(RexShuttle shuttle) { RexNode offset = shuttle.apply(this.offset); RexNode fetch = shuttle.apply(this.fetch); List<RexNode> fieldExps = shuttle.apply(this.fieldExps); assert fieldExps == this.fieldExps : "Sort node does not support modification of input field expressions." + " Old expressions: " + this.fieldExps + ", new ones: " + fieldExps; if (offset == this.offset && fetch == this.fetch) { return this; } return copy(traitSet, getInput(), collation, offset, fetch); }
public RelNode accept(RexShuttle shuttle) { RexNode offset = shuttle.apply(this.offset); RexNode fetch = shuttle.apply(this.fetch); List<RexNode> fieldExps = shuttle.apply(this.fieldExps); assert fieldExps == this.fieldExps : "Sort node does not support modification of input field expressions." + " Old expressions: " + this.fieldExps + ", new ones: " + fieldExps; if (offset == this.offset && fetch == this.fetch) { return this; } return copy(traitSet, getInput(), collation, offset, fetch); }
public void onMatch(RelOptRuleCall call) { final Project project = call.rel(0); final Sort sort = call.rel(1); if (sort.getClass() != Sort.class) { return; } RelNode newProject = project.copy( project.getTraitSet(), ImmutableList.of(sort.getInput())); final Sort newSort = sort.copy( sort.getTraitSet(), newProject, sort.getCollation(), sort.offset, sort.fetch); call.transformTo(newSort); } }
public void onMatch(RelOptRuleCall call) { final Project project = call.rel(0); final Sort sort = call.rel(1); if (sort.getClass() != Sort.class) { return; } RelNode newProject = project.copy( project.getTraitSet(), ImmutableList.of(sort.getInput())); final Sort newSort = sort.copy( sort.getTraitSet(), newProject, sort.getCollation(), sort.offset, sort.fetch); call.transformTo(newSort); } }
sort.copy(sort.getTraitSet(), input, RelCollations.of(collationsList)); call.transformTo(result); call.getPlanner().setImportance(sort, 0.0);
public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); final DruidQuery query = call.rel(1); if (!DruidQuery.isValidSignature(query.signature() + 'l')) { return; } // Either it is: // - a sort and limit on a dimension/metric part of the druid group by query or // - a sort without limit on the time column on top of // Agg operator (transformable to timeseries query), or // - a simple limit on top of other operator than Agg if (!validSortLimit(sort, query)) { return; } final RelNode newSort = sort.copy(sort.getTraitSet(), ImmutableList.of(Util.last(query.rels))); call.transformTo(DruidQuery.extendQuery(query, newSort)); }
public void onMatch(RelOptRuleCall call) { final Sort sort = call.rel(0); final DruidQuery query = call.rel(1); if (!DruidQuery.isValidSignature(query.signature() + 'l')) { return; } // Either it is: // - a pure limit above a query of type scan // - a sort and limit on a dimension/metric part of the druid group by query if (sort.offset != null && RexLiteral.intValue(sort.offset) != 0) { // offset not supported by Druid return; } if (query.getQueryType() == QueryType.SCAN && !RelOptUtil.isPureLimit(sort)) { return; } final RelNode newSort = sort .copy(sort.getTraitSet(), ImmutableList.of(Util.last(query.rels))); call.transformTo(DruidQuery.extendQuery(query, newSort)); } }
@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 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 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)); } }