Search in sources :

Example 96 with HepProgramBuilder

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

the class RelOptRulesTest method testReduceConstantsCaseEquals.

// see HIVE-9644
@Test
public void testReduceConstantsCaseEquals() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
    // Equivalent to 'deptno = 10'
    checkPlanning(program, "select count(1) from emp\n" + "where case deptno\n" + "  when 20 then 2\n" + "  when 10 then 1\n" + "  else 3 end = 1");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 97 with HepProgramBuilder

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

the class RelOptRulesTest method testCustomColumnResolvingInCorrelatedSubQuery2.

@Test
public void testCustomColumnResolvingInCorrelatedSubQuery2() {
    final String sql = "select *\n" + "from struct.t t1\n" + "where c0 in (\n" + "  select f1.c0 from struct.t t2 where t1.c2 = t2.c2)";
    final HepProgram program = new HepProgramBuilder().addRuleInstance(SubQueryRemoveRule.PROJECT).addRuleInstance(SubQueryRemoveRule.FILTER).addRuleInstance(SubQueryRemoveRule.JOIN).build();
    sql(sql).withTrim(true).expand(false).with(program).check();
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 98 with HepProgramBuilder

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

the class RelOptRulesTest method testPushJoinCondDownToProject.

@Test
public void testPushJoinCondDownToProject() {
    final HepProgram program = new HepProgramBuilder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(JoinPushExpressionsRule.INSTANCE).build();
    checkPlanning(program, "select d.deptno, e.deptno from sales.dept d, sales.emp e" + " where d.deptno + 10 = e.deptno * 2");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 99 with HepProgramBuilder

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

the class RelOptRulesTest method testPushAggregateThroughJoin5.

@Test
public void testPushAggregateThroughJoin5() {
    final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
    final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
    final String sql = "select e.deptno, d.deptno\n" + "from sales.emp as e join sales.dept as d on e.deptno = d.deptno\n" + "group by e.deptno, d.deptno";
    sql(sql).withPre(preProgram).with(program).check();
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 100 with HepProgramBuilder

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

the class RelOptRulesTest method testReduceConstantsNegatedInverted.

@Test
public void testReduceConstantsNegatedInverted() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
    final String sql = "select empno from emp where empno>10 and empno<=10";
    checkPlanning(program, sql);
}
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)168 Test (org.junit.Test)147 HepProgram (org.apache.calcite.plan.hep.HepProgram)143 HepPlanner (org.apache.calcite.plan.hep.HepPlanner)56 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