use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testSortJoinTranspose2.
@Test
public void testSortJoinTranspose2() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(SortProjectTransposeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(SortJoinTransposeRule.INSTANCE).build();
final String sql = "select * from sales.emp e right join (\n" + "select * from sales.dept d) using (deptno)\n" + "order by name";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testReduceConstantsDup2.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-935">[CALCITE-935]
* Improve how ReduceExpressionsRule handles duplicate constraints</a>.
*/
@Test
public void testReduceConstantsDup2() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
final String sql = "select *\n" + "from emp\n" + "where deptno=7 and deptno=8\n" + "and empno = 10 and mgr is null and empno = 10";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testPushFilterWithRank.
@Test
public void testPushFilterWithRank() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterProjectTransposeRule.INSTANCE).build();
final String sql = "select e1.ename, r\n" + "from (\n" + " select ename, " + " rank() over(partition by deptno order by sal) as r " + " from emp) e1\n" + "where r < 2";
checkPlanUnchanged(new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testPushAggregateThroughJoin3.
@Test
public void testPushAggregateThroughJoin3() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
final String sql = "select e.empno,d.deptno\n" + "from (select * from sales.emp where empno = 10) as e\n" + "join sales.dept as d on e.empno < d.deptno\n" + "group by e.empno,d.deptno";
checkPlanning(tester, preProgram, new HepPlanner(program), sql, true);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testPushAggregateSumThroughJoin.
/**
* SUM is the easiest aggregate function to split.
*/
@Test
public void testPushAggregateSumThroughJoin() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
final String sql = "select e.job,sum(sal)\n" + "from (select * from sales.emp where empno = 10) as e\n" + "join sales.dept as d on e.job = d.name\n" + "group by e.job,d.name";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
Aggregations