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)); }
@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 RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(OLAPRel.CONVENTION); final RelNode input = sort.getInput(); return new OLAPSortRel(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)), sort.getCollation(), sort.offset, sort.fetch); }
first.getTraitSet(), first.getInput(), first.getCollation(),
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); } }
@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 RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; final RelTraitSet traitSet = sort.getTraitSet().replace(BindableConvention.INSTANCE); final RelNode input = sort.getInput(); return new BindableSort(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(BindableConvention.INSTANCE)), sort.getCollation(), sort.offset, sort.fetch); } }
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 RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; final RelTraitSet traitSet = sort.getTraitSet().replace(BindableConvention.INSTANCE); final RelNode input = sort.getInput(); return new BindableSort(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(BindableConvention.INSTANCE)), sort.getCollation(), sort.offset, sort.fetch); } }
@Override public RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(OLAPRel.CONVENTION); final RelNode input = sort.getInput(); return new OLAPSortRel(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)), sort.getCollation(), sort.offset, sort.fetch); }
@Override public RelNode convert(RelNode relNode) { final Sort sort = (Sort) relNode; final RelTraitSet traitSet = sort.getTraitSet().replace(out).replace(sort.getCollation()); return new ElasticsearchSort(relNode.getCluster(), traitSet, convert(sort.getInput(), traitSet.replace(RelCollations.EMPTY)), 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); } }
/** * 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 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) { if (!call.getPlanner().getRelTraitDefs() .contains(RelCollationTraitDef.INSTANCE)) { // Collation is not an active trait. return; } final Sort sort = call.rel(0); if (sort.offset != null || sort.fetch != null) { // Don't remove sort if would also remove OFFSET or LIMIT. return; } // Express the "sortedness" requirement in terms of a collation trait and // we can get rid of the sort. This allows us to use rels that just happen // to be sorted but get the same effect. final RelCollation collation = sort.getCollation(); assert collation == sort.getTraitSet() .getTrait(RelCollationTraitDef.INSTANCE); final RelTraitSet traits = sort.getInput().getTraitSet().replace(collation); call.transformTo(convert(sort.getInput(), traits)); } }
@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 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)); }