Search in sources :

Example 1 with RelTraitSet

use of org.apache.calcite.plan.RelTraitSet in project storm by apache.

the class QueryPlanner method convertToStormRel.

private RelNode convertToStormRel(RelNode relNode) throws RelConversionException {
    RelTraitSet traitSet = relNode.getTraitSet();
    traitSet = traitSet.simplify();
    // PlannerImpl.transform() optimizes RelNode with ruleset
    return planner.transform(STORM_REL_CONVERSION_RULES, traitSet.plus(TridentLogicalConvention.INSTANCE), relNode);
}
Also used : RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 2 with RelTraitSet

use of org.apache.calcite.plan.RelTraitSet in project hive by apache.

the class HiveSortExchange method create.

/**
   * Creates a HiveSortExchange.
   *
   * @param input     Input relational expression
   * @param distribution Distribution specification
   * @param collation Collation specification
   * @param joinKeys Join Keys specification
   */
public static HiveSortExchange create(RelNode input, RelDistribution distribution, RelCollation collation, ImmutableList<RexNode> joinKeys) {
    RelOptCluster cluster = input.getCluster();
    distribution = RelDistributionTraitDef.INSTANCE.canonize(distribution);
    collation = RelCollationTraitDef.INSTANCE.canonize(collation);
    RelTraitSet traitSet = RelTraitSet.createEmpty().plus(distribution).plus(collation);
    return new HiveSortExchange(cluster, traitSet, input, distribution, collation, joinKeys);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 3 with RelTraitSet

use of org.apache.calcite.plan.RelTraitSet in project hive by apache.

the class HiveSortLimit method create.

/**
   * Creates a HiveSortLimit.
   *
   * @param input     Input relational expression
   * @param collation array of sort specifications
   * @param offset    Expression for number of rows to discard before returning
   *                  first row
   * @param fetch     Expression for number of rows to fetch
   */
public static HiveSortLimit create(RelNode input, RelCollation collation, RexNode offset, RexNode fetch) {
    RelOptCluster cluster = input.getCluster();
    collation = RelCollationTraitDef.INSTANCE.canonize(collation);
    RelTraitSet traitSet = TraitsUtil.getSortTraitSet(cluster, input.getTraitSet(), collation);
    return new HiveSortLimit(cluster, traitSet, input, collation, offset, fetch);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 4 with RelTraitSet

use of org.apache.calcite.plan.RelTraitSet in project drill by apache.

the class DirPrunedEnumerableTableScan method create.

/** Creates an DirPrunedEnumerableTableScan. */
public static EnumerableTableScan create(RelOptCluster cluster, RelOptTable relOptTable, String digestFromSelection) {
    final Table table = relOptTable.unwrap(Table.class);
    Class elementType = EnumerableTableScan.deduceElementType(table);
    final RelTraitSet traitSet = cluster.traitSetOf(EnumerableConvention.INSTANCE).replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() {

        public List<RelCollation> get() {
            if (table != null) {
                return table.getStatistic().getCollations();
            }
            return ImmutableList.of();
        }
    });
    return new DirPrunedEnumerableTableScan(cluster, traitSet, relOptTable, elementType, digestFromSelection);
}
Also used : Table(org.apache.calcite.schema.Table) RelOptTable(org.apache.calcite.plan.RelOptTable) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 5 with RelTraitSet

use of org.apache.calcite.plan.RelTraitSet in project drill by apache.

the class DrillLimitRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final Sort incomingSort = call.rel(0);
    final RelTraitSet incomingTraits = incomingSort.getTraitSet();
    RelNode input = incomingSort.getInput();
    // 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));
    call.transformTo(new DrillLimitRel(incomingSort.getCluster(), convertedInput.getTraitSet().plus(DrillRel.DRILL_LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) LogicalSort(org.apache.calcite.rel.logical.LogicalSort) Sort(org.apache.calcite.rel.core.Sort) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Aggregations

RelTraitSet (org.apache.calcite.plan.RelTraitSet)36 RelNode (org.apache.calcite.rel.RelNode)25 InvalidRelException (org.apache.calcite.rel.InvalidRelException)8 ArrayList (java.util.ArrayList)4 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)4 RexNode (org.apache.calcite.rex.RexNode)4 RelOptCluster (org.apache.calcite.plan.RelOptCluster)3 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)3 RelCollation (org.apache.calcite.rel.RelCollation)3 Stopwatch (com.google.common.base.Stopwatch)2 ImmutableList (com.google.common.collect.ImmutableList)2 RelOptTable (org.apache.calcite.plan.RelOptTable)2 Sort (org.apache.calcite.rel.core.Sort)2 Window (org.apache.calcite.rel.core.Window)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 RexInputRef (org.apache.calcite.rex.RexInputRef)2 Table (org.apache.calcite.schema.Table)2 DrillAggregateRel (org.apache.drill.exec.planner.logical.DrillAggregateRel)2 DrillDirectScanRel (org.apache.drill.exec.planner.logical.DrillDirectScanRel)2 DrillRel (org.apache.drill.exec.planner.logical.DrillRel)2