Search in sources :

Example 26 with Union

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Union in project beam by apache.

the class BeamUnionRelTest method testNodeStatsEstimationUnionAll.

@Test
public void testNodeStatsEstimationUnionAll() {
    String sql = "SELECT " + " order_id, site_id, price " + "FROM ORDER_DETAILS " + " UNION ALL SELECT " + " order_id, site_id, price " + "FROM ORDER_DETAILS ";
    RelNode root = env.parseQuery(sql);
    while (!(root instanceof BeamUnionRel)) {
        root = root.getInput(0);
    }
    NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
    Assert.assertFalse(estimate.isUnknown());
    Assert.assertEquals(0d, estimate.getRate(), 0.01);
    Assert.assertEquals(4., estimate.getRowCount(), 0.01);
    Assert.assertEquals(4., estimate.getWindow(), 0.01);
}
Also used : NodeStats(org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats) BeamRelMetadataQuery(org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery) RelNode(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode) Test(org.junit.Test)

Example 27 with Union

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

the class DruidUnionDataSourceRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    final Union unionRel = call.rel(0);
    final DruidRel<?> firstDruidRel = call.rel(1);
    final DruidQueryRel secondDruidRel = call.rel(2);
    return isCompatible(unionRel, firstDruidRel, secondDruidRel, plannerContext);
}
Also used : DruidQueryRel(org.apache.druid.sql.calcite.rel.DruidQueryRel) Union(org.apache.calcite.rel.core.Union)

Example 28 with Union

use of org.apache.beam.vendor.calcite.v1_28_0.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 29 with Union

use of org.apache.beam.vendor.calcite.v1_28_0.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 30 with Union

use of org.apache.beam.vendor.calcite.v1_28_0.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)41 RelNode (org.apache.calcite.rel.RelNode)28 Aggregate (org.apache.calcite.rel.core.Aggregate)15 Sort (org.apache.calcite.rel.core.Sort)13 ArrayList (java.util.ArrayList)12 RexNode (org.apache.calcite.rex.RexNode)12 Join (org.apache.calcite.rel.core.Join)11 Filter (org.apache.calcite.rel.core.Filter)10 Project (org.apache.calcite.rel.core.Project)10 RelBuilder (org.apache.calcite.tools.RelBuilder)10 TableScan (org.apache.calcite.rel.core.TableScan)9 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)9 RexBuilder (org.apache.calcite.rex.RexBuilder)9 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)9 Intersect (org.apache.calcite.rel.core.Intersect)8 Minus (org.apache.calcite.rel.core.Minus)8 Correlate (org.apache.calcite.rel.core.Correlate)7 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)7 Map (java.util.Map)6 Calc (org.apache.calcite.rel.core.Calc)6