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");
}
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();
}
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");
}
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();
}
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);
}
Aggregations