@Override public List<RelCollation> getCollationList() { // TODO: include each prefix of the collation, e.g [[x, y], [x], []] return Collections.singletonList(getCollation()); }
@Override public List<RelCollation> getCollationList() { // TODO: include each prefix of the collation, e.g [[x, y], [x], []] return Collections.singletonList(getCollation()); }
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()); } }
final RelDataType rowType = sort.getRowType(); final int fieldCount = rowType.getFieldCount(); final RelCollation collation = sort.getCollation(); final RelNode input = sort.getChild();
final RelCollation collation = sort.getCollation(); final RelNode input = sort.getChild();
newChildRel.getRowType().getFieldCount()); RelCollation oldCollation = rel.getCollation(); RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
@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()) { // 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)); } }
newChildRel.getRowType().getFieldCount()); RelCollation oldCollation = rel.getCollation(); RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
@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); } }
RelOptUtil.permutation( project.getProjects(), project.getChild().getRowType()); for (RelFieldCollation fc : sort.getCollation().getFieldCollations()) { if (map.getTargetOpt(fc.getFieldIndex()) < 0) { return; RexUtil.apply(map, sort.getCollation())); final SortRel newSort = sort.copy(
@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)); } }
public void rewriteRel(SortRel rel) { RelCollation oldCollation = rel.getCollation(); final RelNode oldChild = rel.getChild(); final RelNode newChild = getNewForOldRel(oldChild); final Mappings.TargetMapping mapping = getNewForOldInputMapping(oldChild); // validate for (RelFieldCollation field : oldCollation.getFieldCollations()) { int oldInput = field.getFieldIndex(); RelDataType sortFieldType = oldChild.getRowType().getFieldList().get(oldInput).getType(); if (sortFieldType.isStruct()) { // TODO jvs 10-Feb-2005 throw Util.needToImplement("sorting on structured types"); } } SortRel newRel = new SortRel( rel.getCluster(), rel.getCluster().traitSetOf(Convention.NONE), newChild, RexUtil.apply(mapping, oldCollation)); setNewForOldRel(rel, newRel); }
public void rewriteRel(SortRel rel) { RelCollation oldCollation = rel.getCollation(); final RelNode oldChild = rel.getChild(); final RelNode newChild = getNewForOldRel(oldChild); final Mappings.TargetMapping mapping = getNewForOldInputMapping(oldChild); // validate for (RelFieldCollation field : oldCollation.getFieldCollations()) { int oldInput = field.getFieldIndex(); RelDataType sortFieldType = oldChild.getRowType().getFieldList().get(oldInput).getType(); if (sortFieldType.isStruct()) { // TODO jvs 10-Feb-2005 throw Util.needToImplement("sorting on structured types"); } } RelCollation newCollation = RexUtil.apply(mapping, oldCollation); SortRel newRel = new SortRel( rel.getCluster(), rel.getCluster().traitSetOf(Convention.NONE).plus(newCollation), newChild, newCollation, rel.offset, rel.fetch); setNewForOldRel(rel, newRel); }