Search in sources :

Example 16 with RelTraitSet

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

the class DrillProjectRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final Project project = (Project) call.rel(0);
    final RelNode input = project.getInput();
    final RelTraitSet traits = project.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
    final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
    call.transformTo(new DrillProjectRel(project.getCluster(), traits, convertedInput, project.getProjects(), project.getRowType()));
}
Also used : Project(org.apache.calcite.rel.core.Project) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) RelNode(org.apache.calcite.rel.RelNode) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 17 with RelTraitSet

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

the class DrillValuesRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final LogicalValues values = (LogicalValues) call.rel(0);
    final RelTraitSet traits = values.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
    call.transformTo(new DrillValuesRel(values.getCluster(), values.getRowType(), values.getTuples(), traits));
}
Also used : RelTraitSet(org.apache.calcite.plan.RelTraitSet) LogicalValues(org.apache.calcite.rel.logical.LogicalValues)

Example 18 with RelTraitSet

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

the class DrillWindowRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final Window window = call.rel(0);
    final RelNode input = call.rel(1);
    final RelTraitSet traits = window.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
    final RelNode convertedInput = convert(input, traits);
    call.transformTo(new DrillWindowRel(window.getCluster(), traits, convertedInput, window.constants, window.getRowType(), window.groups));
}
Also used : Window(org.apache.calcite.rel.core.Window) RelNode(org.apache.calcite.rel.RelNode) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 19 with RelTraitSet

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

the class DrillSortRule method onMatch.

@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));
    call.transformTo(new DrillSortRel(sort.getCluster(), traits, convertedInput, sort.getCollation()));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) Sort(org.apache.calcite.rel.core.Sort) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 20 with RelTraitSet

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

the class DrillUnionAllRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final LogicalUnion union = (LogicalUnion) call.rel(0);
    // This rule applies to Union-All only
    if (!union.all) {
        return;
    }
    final RelTraitSet traits = union.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
    final List<RelNode> convertedInputs = new ArrayList<>();
    for (RelNode input : union.getInputs()) {
        final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
        convertedInputs.add(convertedInput);
    }
    try {
        call.transformTo(new DrillUnionRel(union.getCluster(), traits, convertedInputs, union.all, true));
    } catch (InvalidRelException e) {
        tracer.warning(e.toString());
    }
}
Also used : InvalidRelException(org.apache.calcite.rel.InvalidRelException) LogicalUnion(org.apache.calcite.rel.logical.LogicalUnion) RelNode(org.apache.calcite.rel.RelNode) ArrayList(java.util.ArrayList) 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