Search in sources :

Example 1 with LogicalUnion

use of org.apache.calcite.rel.logical.LogicalUnion 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

ArrayList (java.util.ArrayList)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 InvalidRelException (org.apache.calcite.rel.InvalidRelException)1 RelNode (org.apache.calcite.rel.RelNode)1 LogicalUnion (org.apache.calcite.rel.logical.LogicalUnion)1