Search in sources :

Example 16 with HepProgramBuilder

use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.

the class RelOptRulesTest method testEmptyJoinLeft.

@Test
public void testEmptyJoinLeft() {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(PruneEmptyRules.PROJECT_INSTANCE).addRuleInstance(PruneEmptyRules.JOIN_LEFT_INSTANCE).addRuleInstance(PruneEmptyRules.JOIN_RIGHT_INSTANCE).build();
    // Plan should be empty
    checkPlanning(program, "select * from (\n" + "select * from emp where false)\n" + "left join dept using (deptno)");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 17 with HepProgramBuilder

use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.

the class RelOptRulesTest method testReduceConstantsIsNotNull.

@Test
public void testReduceConstantsIsNotNull() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
    final String sql = "select empno from emp\n" + "where empno=10 and empno is not null";
    checkPlanning(program, sql);
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 18 with HepProgramBuilder

use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.

the class RelOptRulesTest method testSortProjectTranspose3.

@Test
public void testSortProjectTranspose3() {
    final HepProgram program = new HepProgramBuilder().addRuleInstance(SortProjectTransposeRule.INSTANCE).build();
    // This one cannot be pushed down
    final String sql = "select d.deptno from sales.dept d\n" + "order by cast(d.deptno as varchar(10)) offset 1";
    sql(sql).with(program).checkUnchanged();
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 19 with HepProgramBuilder

use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.

the class RelOptRulesTest method testReduceNullableCase2.

@Test
public void testReduceNullableCase2() {
    HepProgramBuilder builder = new HepProgramBuilder();
    builder.addRuleClass(ReduceExpressionsRule.class);
    HepPlanner hepPlanner = new HepPlanner(builder.build());
    hepPlanner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE);
    final String sql = "SELECT deptno, ename, CASE WHEN 1=2 " + "THEN substring(ename, 1, cast(2 as int)) ELSE NULL end from emp" + " group by deptno, ename, case when 1=2 then substring(ename,1, cast(2 as int))  else null end";
    sql(sql).with(hepPlanner).check();
}
Also used : HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) Test(org.junit.Test)

Example 20 with HepProgramBuilder

use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.

the class RelOptRulesTest method testRemoveSemiJoinRight.

@Test
public void testRemoveSemiJoinRight() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(JoinAddRedundantSemiJoinRule.INSTANCE).addRuleInstance(SemiJoinJoinTransposeRule.INSTANCE).addRuleInstance(SemiJoinRemoveRule.INSTANCE).build();
    checkPlanning(program, "select e1.ename from emp e1, dept d, emp e2 " + "where e1.deptno = d.deptno and d.deptno = e2.deptno");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Aggregations

HepProgramBuilder (org.apache.calcite.plan.hep.HepProgramBuilder)167 Test (org.junit.Test)147 HepProgram (org.apache.calcite.plan.hep.HepProgram)142 HepPlanner (org.apache.calcite.plan.hep.HepPlanner)55 RelNode (org.apache.calcite.rel.RelNode)9 RelOptRule (org.apache.calcite.plan.RelOptRule)5 RelDataType (org.apache.calcite.rel.type.RelDataType)5 RexBuilder (org.apache.calcite.rex.RexBuilder)5 JavaTypeFactoryImpl (org.apache.calcite.jdbc.JavaTypeFactoryImpl)4 RelOptCluster (org.apache.calcite.plan.RelOptCluster)4 AggregateExtractProjectRule (org.apache.calcite.rel.rules.AggregateExtractProjectRule)4 Ignore (org.junit.Ignore)4 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)3 RelTraitSet (org.apache.calcite.plan.RelTraitSet)3 LogicalTableScan (org.apache.calcite.rel.logical.LogicalTableScan)3 RuleSet (org.apache.calcite.tools.RuleSet)3 Before (org.junit.Before)3 Properties (java.util.Properties)2 CalciteConnectionConfigImpl (org.apache.calcite.config.CalciteConnectionConfigImpl)2 Context (org.apache.calcite.plan.Context)2