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);
}
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);
}
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.");
}
}
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);
}
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);
}
Aggregations