Search in sources :

Example 21 with Union

use of org.apache.calcite.rel.core.Union in project druid by druid-io.

the class DruidUnionRule method onMatch.

@Override
public void onMatch(final RelOptRuleCall call) {
    final Union unionRel = call.rel(0);
    final DruidRel<?> someDruidRel = call.rel(1);
    final List<RelNode> inputs = unionRel.getInputs();
    // Can only do UNION ALL.
    if (unionRel.all) {
        call.transformTo(DruidUnionRel.create(someDruidRel.getPlannerContext(), unionRel.getRowType(), inputs, -1));
    } else {
        plannerContext.setPlanningError("SQL requires 'UNION' but only 'UNION ALL' is supported.");
    }
}
Also used : RelNode(org.apache.calcite.rel.RelNode) Union(org.apache.calcite.rel.core.Union)

Example 22 with Union

use of org.apache.calcite.rel.core.Union in project druid by druid-io.

the class DruidUnionRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    // Make DruidUnionRule and DruidUnionDataSourceRule mutually exclusive.
    final Union unionRel = call.rel(0);
    final DruidRel<?> firstDruidRel = call.rel(1);
    final DruidRel<?> secondDruidRel = call.rel(2);
    return !DruidUnionDataSourceRule.isCompatible(unionRel, firstDruidRel, secondDruidRel, null);
}
Also used : Union(org.apache.calcite.rel.core.Union)

Example 23 with Union

use of org.apache.calcite.rel.core.Union in project drill by apache.

the class PluginConverterRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    RelNode rel = call.rel(0);
    boolean canImplement = false;
    // cannot use visitor pattern here, since RelShuttle supports only logical rel implementations
    if (rel instanceof Aggregate) {
        canImplement = pluginImplementor.canImplement(((Aggregate) rel));
    } else if (rel instanceof Filter) {
        canImplement = pluginImplementor.canImplement(((Filter) rel));
    } else if (rel instanceof DrillLimitRelBase) {
        canImplement = pluginImplementor.canImplement(((DrillLimitRelBase) rel));
    } else if (rel instanceof Project) {
        canImplement = pluginImplementor.canImplement(((Project) rel));
    } else if (rel instanceof Sort) {
        canImplement = pluginImplementor.canImplement(((Sort) rel));
    } else if (rel instanceof Union) {
        canImplement = pluginImplementor.canImplement(((Union) rel));
    } else if (rel instanceof Join) {
        canImplement = pluginImplementor.canImplement(((Join) rel));
    }
    return canImplement && super.matches(call);
}
Also used : Project(org.apache.calcite.rel.core.Project) RelNode(org.apache.calcite.rel.RelNode) Filter(org.apache.calcite.rel.core.Filter) DrillLimitRelBase(org.apache.drill.exec.planner.common.DrillLimitRelBase) Sort(org.apache.calcite.rel.core.Sort) Join(org.apache.calcite.rel.core.Join) Aggregate(org.apache.calcite.rel.core.Aggregate) Union(org.apache.calcite.rel.core.Union)

Aggregations

Union (org.apache.calcite.rel.core.Union)23 RelNode (org.apache.calcite.rel.RelNode)14 RelBuilder (org.apache.calcite.tools.RelBuilder)9 ArrayList (java.util.ArrayList)8 Aggregate (org.apache.calcite.rel.core.Aggregate)7 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)6 RexBuilder (org.apache.calcite.rex.RexBuilder)6 RexNode (org.apache.calcite.rex.RexNode)6 Join (org.apache.calcite.rel.core.Join)4 Sort (org.apache.calcite.rel.core.Sort)4 LogicalUnion (org.apache.calcite.rel.logical.LogicalUnion)4 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)4 RelOptPredicateList (org.apache.calcite.plan.RelOptPredicateList)3 Filter (org.apache.calcite.rel.core.Filter)3 Project (org.apache.calcite.rel.core.Project)3 SetOp (org.apache.calcite.rel.core.SetOp)3 HashMap (java.util.HashMap)2 Intersect (org.apache.calcite.rel.core.Intersect)2 Minus (org.apache.calcite.rel.core.Minus)2 TableScan (org.apache.calcite.rel.core.TableScan)2