Search in sources :

Example 11 with BeamIOSourceRel

use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSourceRel 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

BeamIOSourceRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSourceRel)11 BeamRelNode (org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode)7 Test (org.junit.Test)7 BeamAggregationRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamAggregationRel)4 BeamPushDownIOSourceRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamPushDownIOSourceRel)3 Row (org.apache.beam.sdk.values.Row)3 BeamCalcRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamCalcRel)2 RelNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode)2 Project (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Project)2 RelDataType (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType)2 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 BeamSqlTable (org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable)1 BeamSqlTableFilter (org.apache.beam.sdk.extensions.sql.meta.BeamSqlTableFilter)1 DefaultTableFilter (org.apache.beam.sdk.extensions.sql.meta.DefaultTableFilter)1 FieldAccessDescriptor (org.apache.beam.sdk.schemas.FieldAccessDescriptor)1 Schema (org.apache.beam.sdk.schemas.Schema)1 ImmutableList (org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList)1 RelSubset (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.volcano.RelSubset)1