org.apache.calcite.rel.logical.LogicalSort Java Examples
The following examples show how to use
org.apache.calcite.rel.logical.LogicalSort.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelStructuredTypeFlattener.java From calcite with Apache License 2.0 | 6 votes |
public void rewriteRel(Sort rel) { RelCollation oldCollation = rel.getCollation(); final RelNode oldChild = rel.getInput(); 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); Sort newRel = LogicalSort.create(newChild, newCollation, rel.offset, rel.fetch); setNewForOldRel(rel, newRel); }
Example #2
Source File: RelCollationTraitDef.java From calcite with Apache License 2.0 | 6 votes |
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { // An empty sort doesn't make sense. return null; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Sort sort = LogicalSort.create(rel, toCollation, null, null); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
Example #3
Source File: RelCollationTraitDef.java From Bats with Apache License 2.0 | 6 votes |
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { // An empty sort doesn't make sense. return null; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Sort sort = LogicalSort.create(rel, toCollation, null, null); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
Example #4
Source File: RelStructuredTypeFlattener.java From Bats with Apache License 2.0 | 6 votes |
public void rewriteRel(Sort rel) { RelCollation oldCollation = rel.getCollation(); final RelNode oldChild = rel.getInput(); 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); Sort newRel = LogicalSort.create(newChild, newCollation, rel.offset, rel.fetch); setNewForOldRel(rel, newRel); }
Example #5
Source File: StreamRules.java From Bats with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Sort sort = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(sort.getInput()); final LogicalSort newSort = LogicalSort.create(newDelta, sort.collation, sort.offset, sort.fetch); call.transformTo(newSort); }
Example #6
Source File: StreamRules.java From calcite with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Sort sort = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(sort.getInput()); final LogicalSort newSort = LogicalSort.create(newDelta, sort.collation, sort.offset, sort.fetch); call.transformTo(newSort); }
Example #7
Source File: CopyWithCluster.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelNode visit(LogicalSort sort) { final RelNode input = sort.getInput().accept(this); return new LogicalSort( cluster, copyOf(sort.getTraitSet()), input, sort.getCollation(), copyOf(sort.offset), copyOf(sort.fetch) ); }
Example #8
Source File: ElasticsearchSortRule.java From dk-fitting with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode relNode) { final LogicalSort sort = (LogicalSort) relNode; final RelTraitSet traitSet = sort.getTraitSet().replace(getOutTrait()).replace(sort.getCollation()); return new ElasticsearchSort(relNode.getCluster(), traitSet, convert(sort.getInput(), traitSet.replace(RelCollations.EMPTY)), sort.getCollation(), sort.offset, sort.fetch); }
Example #9
Source File: ElasticsearchSortRule.java From dk-fitting with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode relNode) { final LogicalSort sort = (LogicalSort) relNode; final RelTraitSet traitSet = sort.getTraitSet().replace(getOutTrait()).replace(sort.getCollation()); return new ElasticsearchSort(relNode.getCluster(), traitSet, convert(sort.getInput(), traitSet.replace(RelCollations.EMPTY)), sort.getCollation(), sort.offset, sort.fetch); }
Example #10
Source File: FindLimit0Visitor.java From Bats with Apache License 2.0 | 5 votes |
@Override public RelNode visit(LogicalSort sort) { if (DrillRelOptUtil.isLimit0(sort.fetch)) { contains = true; return sort; } return super.visit(sort); }
Example #11
Source File: LimitRule.java From dremio-oss with Apache License 2.0 | 4 votes |
private LimitRule() { super(RelOptHelper.any(LogicalSort.class, Convention.NONE), "LimitRule"); }
Example #12
Source File: SqlToRelConverterTest.java From calcite with Apache License 2.0 | 4 votes |
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-3183">[CALCITE-3183] * Trimming method for Filter rel uses wrong traitSet</a>. */ @Test void testFilterAndSortWithTrim() { // Create a customized test with RelCollation trait in the test cluster. Tester tester = new TesterImpl(getDiffRepos(), false, true, true, false, true, null, null) { @Override public RelOptPlanner createPlanner() { return new MockRelOptPlanner(Contexts.empty()) { @Override public List<RelTraitDef> getRelTraitDefs() { return ImmutableList.<RelTraitDef>of(RelCollationTraitDef.INSTANCE); } @Override public RelTraitSet emptyTraitSet() { return RelTraitSet.createEmpty().plus( RelCollationTraitDef.INSTANCE.getDefault()); } }; } }; // Run query and save plan after trimming final String sql = "select count(a.EMPNO)\n" + "from (select * from emp order by sal limit 3) a\n" + "where a.EMPNO > 10 group by 2"; RelNode afterTrim = tester.convertSqlToRel(sql).rel; // Get Sort and Filter operators final List<RelNode> rels = new ArrayList<>(); final RelShuttleImpl visitor = new RelShuttleImpl() { @Override public RelNode visit(LogicalSort sort) { rels.add(sort); return super.visit(sort); } @Override public RelNode visit(LogicalFilter filter) { rels.add(filter); return super.visit(filter); } }; visitor.visit(afterTrim); // Ensure sort and filter operators have consistent traitSet after trimming assertThat(rels.size(), is(2)); RelTrait filterCollation = rels.get(0).getTraitSet() .getTrait(RelCollationTraitDef.INSTANCE); RelTrait sortCollation = rels.get(1).getTraitSet() .getTrait(RelCollationTraitDef.INSTANCE); assertTrue(filterCollation.satisfies(sortCollation)); }
Example #13
Source File: CalciteMaterializer.java From calcite with Apache License 2.0 | 4 votes |
public RelNode visit(LogicalSort sort) { return sort; }
Example #14
Source File: RelFactories.java From calcite with Apache License 2.0 | 4 votes |
public RelNode createSort(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { return LogicalSort.create(input, collation, offset, fetch); }
Example #15
Source File: RelHomogeneousShuttle.java From Bats with Apache License 2.0 | 4 votes |
@Override public RelNode visit(LogicalSort sort) { return visit((RelNode) sort); }
Example #16
Source File: RelShuttleImpl.java From calcite with Apache License 2.0 | 4 votes |
public RelNode visit(LogicalSort sort) { return visitChildren(sort); }
Example #17
Source File: RelHomogeneousShuttle.java From calcite with Apache License 2.0 | 4 votes |
@Override public RelNode visit(LogicalSort sort) { return visit((RelNode) sort); }
Example #18
Source File: RelShuttleImpl.java From Bats with Apache License 2.0 | 4 votes |
public RelNode visit(LogicalSort sort) { return visitChildren(sort); }
Example #19
Source File: SortRule.java From dremio-oss with Apache License 2.0 | 4 votes |
private SortRule() { super(RelOptHelper.any(LogicalSort.class, Convention.NONE), "SortRule"); }
Example #20
Source File: RoutingShuttle.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public RelNode visit(LogicalSort sort) { return visit((RelNode) sort); }
Example #21
Source File: RelFactories.java From Bats with Apache License 2.0 | 4 votes |
public RelNode createSort(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { return LogicalSort.create(input, collation, offset, fetch); }
Example #22
Source File: DrillLimitRule.java From Bats with Apache License 2.0 | 4 votes |
private DrillLimitRule() { super(RelOptHelper.any(LogicalSort.class, Convention.NONE), DrillRelFactories.LOGICAL_BUILDER, "DrillLimitRule"); }
Example #23
Source File: ElasticsearchSortRule.java From dk-fitting with Apache License 2.0 | 4 votes |
ElasticsearchSortRule(){ super(LogicalSort.class, Convention.NONE, ElasticsearchRelNode.CONVENTION, ElasticsearchSortRule.class.getSimpleName()); }
Example #24
Source File: DrillReduceExpressionsRule.java From Bats with Apache License 2.0 | 4 votes |
private static RelNode createEmptyEmptyRelHelper(SingleRel input) { return LogicalSort.create(input.getInput(), RelCollations.EMPTY, input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)), input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0))); }
Example #25
Source File: ElasticsearchSortRule.java From dk-fitting with Apache License 2.0 | 4 votes |
ElasticsearchSortRule(){ super(LogicalSort.class, Convention.NONE, ElasticsearchRelNode.CONVENTION, ElasticsearchSortRule.class.getSimpleName()); }
Example #26
Source File: JoinUtils.java From Bats with Apache License 2.0 | 4 votes |
@Override public RelNode visit(LogicalSort sort) { return sort; }
Example #27
Source File: RelShuttle.java From calcite with Apache License 2.0 | votes |
RelNode visit(LogicalSort sort);
Example #28
Source File: RelShuttle.java From Bats with Apache License 2.0 | votes |
RelNode visit(LogicalSort sort);