public void onMatch(RelOptRuleCall call) { ProjectRel project = call.rel(0); SortRel sort = call.rel(1); if (sort.getClass() != SortRel.class) { return; } RelNode newProject = project.copy( project.getTraitSet(), ImmutableList.of(sort.getChild())); final SortRel newSort = sort.copy( sort.getTraitSet(), newProject, sort.getCollation(), sort.offset, sort.fetch); call.transformTo(newSort); } }
public RelNode convert(RelNode rel) { final SortRel sort = (SortRel) rel; if (sort.offset != null || sort.fetch != null) { // Cannot implement "OFFSET n FETCH n" currently. return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(out); return new JdbcSortRel(rel.getCluster(), traitSet, convert(sort.getChild(), traitSet), sort.getCollation()); } }
public RelNode convert(RelNode rel) { final SortRel sort = (SortRel) rel; if (sort.offset != null || sort.fetch != null) { // Cannot implement "OFFSET n FETCH n" currently. return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(out); return new JdbcSortRel(rel.getCluster(), traitSet, convert(sort.getChild(), traitSet), sort.getCollation()); } }
sort.getTraitSet(), newInput, RexUtil.apply(inputMapping, collation));
sort.getTraitSet(), newInput, RexUtil.apply(inputMapping, collation));
@Override public void onMatch(RelOptRuleCall call) { if (!call.getPlanner().getRelTraitDefs() .contains(RelCollationTraitDef.INSTANCE)) { // Collation is not an active trait. return; } final SortRel sort = call.rel(0); if (sort.offset != null || sort.fetch != null) { // Don't remove sort if would also remove OFFSET or LIMIT. return; } final RelCollation collation = sort.getCollation(); final RelTraitSet traits = sort.getTraitSet().replace(collation); call.transformTo(convert(sort.getChild(), traits)); } }
@Override public void onMatch(RelOptRuleCall call) { final SortRel sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); RelNode input = sort.getChild(); if (!sort.getCollation().getFieldCollations().isEmpty()) { input = sort.copy( sort.getTraitSet().replace(RelCollationImpl.EMPTY), input, RelCollationImpl.EMPTY, null, null); } RelNode x = convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)); call.transformTo( new EnumerableLimitRel( sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); } }
@Override public void onMatch(RelOptRuleCall call) { final SortRel sort = call.rel(0); if (sort.offset == null && sort.fetch == null) { return; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); RelNode input = sort.getChild(); 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 EnumerableLimitRel( sort.getCluster(), traitSet, x, sort.offset, sort.fetch)); } }
@Override public void onMatch( RelOptRuleCall call ) { SortRel rel = call.rel( 0 ); // Cascading sort does not implement limits if( rel.offset != null || rel.fetch != null ) return; RelTraitSet newTraits = rel.getTraitSet().plus( Cascading.CONVENTION ); call.transformTo( new CascadingSortRel( rel.getCluster(), newTraits, convert( rel.getChild(), newTraits ), rel.getCollation(), rel.offset, rel.fetch ) ); } }
@Override public void onMatch(RelOptRuleCall call) { if (!call.getPlanner().getRelTraitDefs() .contains(RelCollationTraitDef.INSTANCE)) { // Collation is not an active trait. return; } final SortRel 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.getChild().getTraitSet().replace(collation); call.transformTo(convert(sort.getChild(), traits)); } }
public RelNode convert(RelNode rel) { final SortRel sort = (SortRel) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); final RelNode input = sort.getChild(); return new EnumerableSortRel( rel.getCluster(), traitSet, convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), sort.getCollation(), null, null); } }
public RelNode convert(RelNode rel) { final SortRel sort = (SortRel) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelTraitSet traitSet = sort.getTraitSet().replace(EnumerableConvention.INSTANCE); final RelNode input = sort.getChild(); return new EnumerableSortRel( rel.getCluster(), traitSet, convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), sort.getCollation(), null, null); } }
final SortRel newSort = sort.copy( sort.getTraitSet().replace(newCollation), project.getChild(), newCollation, RelNode newProject = project.copy( sort.getTraitSet(), ImmutableList.<RelNode>of(newSort));