Search in sources :

Example 41 with Project

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

the class DruidRelsTest method test_isScanOrMapping_nonMappingUnion.

@Test
public void test_isScanOrMapping_nonMappingUnion() {
    final Project project = mockNonMappingProject();
    final DruidRel<?> rel = mockDruidRel(DruidUnionDataSourceRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, null);
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, true));
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
    EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
Also used : Project(org.apache.calcite.rel.core.Project) Test(org.junit.Test)

Example 42 with Project

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

the class DruidRelsTest method test_isScanOrMapping_filterThenProject.

@Test
public void test_isScanOrMapping_filterThenProject() {
    final Project project = mockMappingProject(ImmutableList.of(1, 0), 2);
    final DruidRel<?> rel = mockDruidRel(DruidQueryRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, mockFilter());
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, true));
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
    EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
Also used : Project(org.apache.calcite.rel.core.Project) Test(org.junit.Test)

Example 43 with Project

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

the class DruidRelsTest method test_isScanOrMapping_mappingJoin.

@Test
public void test_isScanOrMapping_mappingJoin() {
    final Project project = mockMappingProject(ImmutableList.of(1, 0), 2);
    final DruidRel<?> rel = mockDruidRel(DruidJoinQueryRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, null);
    Assert.assertTrue(DruidRels.isScanOrMapping(rel, true));
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
    EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
Also used : Project(org.apache.calcite.rel.core.Project) Test(org.junit.Test)

Example 44 with Project

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

the class DruidRelsTest method test_isScanOrMapping_mappingUnion.

@Test
public void test_isScanOrMapping_mappingUnion() {
    final Project project = mockMappingProject(ImmutableList.of(1, 0), 2);
    final DruidRel<?> rel = mockDruidRel(DruidUnionDataSourceRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, null);
    Assert.assertTrue(DruidRels.isScanOrMapping(rel, true));
    Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
    EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
Also used : Project(org.apache.calcite.rel.core.Project) Test(org.junit.Test)

Example 45 with Project

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

the class IOPushDownRuleTest method testIsProjectRenameOnlyProgram.

@Test
public void testIsProjectRenameOnlyProgram() {
    List<Pair<Pair<String, Boolean>, Boolean>> tests = ImmutableList.of(// Selecting fields in a different order is only allowed with project push-down.
    Pair.of(Pair.of("select unused2, name, id from TEST", true), true), Pair.of(Pair.of("select unused2, name, id from TEST", false), false), Pair.of(Pair.of("select id from TEST", false), true), Pair.of(Pair.of("select * from TEST", false), true), Pair.of(Pair.of("select id, name from TEST", false), true), Pair.of(Pair.of("select id+10 from TEST", false), false), // Note that we only care about projects.
    Pair.of(Pair.of("select id from TEST where name='one'", false), true));
    for (Pair<Pair<String, Boolean>, Boolean> test : tests) {
        String sqlQuery = test.left.left;
        boolean projectPushDownSupported = test.left.right;
        boolean expectedAnswer = test.right;
        BeamRelNode basicRel = sqlEnv.parseQuery(sqlQuery);
        assertThat(basicRel, instanceOf(Calc.class));
        Calc calc = (Calc) basicRel;
        assertThat(test.toString(), BeamIOPushDownRule.INSTANCE.isProjectRenameOnlyProgram(calc.getProgram(), projectPushDownSupported), equalTo(expectedAnswer));
    }
}
Also used : BeamRelNode(org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode) Calc(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Calc) Pair(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.util.Pair) Test(org.junit.Test)

Aggregations

Project (org.apache.calcite.rel.core.Project)143 RexNode (org.apache.calcite.rex.RexNode)77 RelNode (org.apache.calcite.rel.RelNode)71 ArrayList (java.util.ArrayList)51 LogicalProject (org.apache.calcite.rel.logical.LogicalProject)35 RexBuilder (org.apache.calcite.rex.RexBuilder)28 RelDataType (org.apache.calcite.rel.type.RelDataType)26 Test (org.junit.Test)23 Aggregate (org.apache.calcite.rel.core.Aggregate)22 Filter (org.apache.calcite.rel.core.Filter)22 Join (org.apache.calcite.rel.core.Join)22 List (java.util.List)20 RexLiteral (org.apache.calcite.rex.RexLiteral)19 AggregateCall (org.apache.calcite.rel.core.AggregateCall)18 Sort (org.apache.calcite.rel.core.Sort)18 RelBuilder (org.apache.calcite.tools.RelBuilder)17 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)16 HiveProject (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject)16 Collectors (java.util.stream.Collectors)15 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)15