Search in sources :

Example 6 with BeamAggregationRel

use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamAggregationRel in project beam by apache.

the class BeamAggregateProjectMergeRuleTest method testBeamAggregateProjectMergeRule_withProjectTable.

@Test
public void testBeamAggregateProjectMergeRule_withProjectTable() {
    // When an IO supports project push-down, Projects should be merged with an IO.
    String sqlQuery = "select SUM(id) as id_sum from TEST_PROJECT group by name";
    BeamRelNode beamRel = sqlEnv.parseQuery(sqlQuery);
    BeamAggregationRel aggregate = (BeamAggregationRel) beamRel.getInput(0);
    BeamIOSourceRel ioSourceRel = (BeamIOSourceRel) aggregate.getInput();
    // Make sure project push-down took place.
    assertThat(ioSourceRel, instanceOf(BeamPushDownIOSourceRel.class));
    assertThat(ioSourceRel.getRowType().getFieldNames(), containsInAnyOrder("name", "id"));
}
Also used : BeamRelNode(org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode) BeamPushDownIOSourceRel(org.apache.beam.sdk.extensions.sql.impl.rel.BeamPushDownIOSourceRel) BeamAggregationRel(org.apache.beam.sdk.extensions.sql.impl.rel.BeamAggregationRel) BeamIOSourceRel(org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSourceRel) Test(org.junit.Test)

Aggregations

BeamAggregationRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamAggregationRel)6 BeamIOSourceRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSourceRel)4 BeamRelNode (org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode)4 Test (org.junit.Test)4 BeamPushDownIOSourceRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamPushDownIOSourceRel)2 Project (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Project)2 ArrayList (java.util.ArrayList)1 BeamCalcRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel)1 WindowFn (org.apache.beam.sdk.transforms.windowing.WindowFn)1 RelNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode)1 Aggregate (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Aggregate)1 Calc (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Calc)1 Filter (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Filter)1 RexCall (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexCall)1 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)1 ImmutableBitSet (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.util.ImmutableBitSet)1