use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSortUnionTranspose3.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-987">[CALCITE-987]
* Push limit 0 will result in an infinite loop</a>.
*/
@Test
public void testSortUnionTranspose3() {
final HepProgram program = HepProgram.builder().addRuleInstance(ProjectSetOpTransposeRule.INSTANCE).addRuleInstance(SortUnionTransposeRule.MATCH_NULL_FETCH).build();
final String sql = "select a.name from dept a\n" + "union all\n" + "select b.name from dept b\n" + "order by name limit 0";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgram 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);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method basePushAggThroughUnion.
private void basePushAggThroughUnion() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ProjectSetOpTransposeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(AggregateUnionTransposeRule.INSTANCE).build();
checkPlanning(program, "${sql}");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testAggregateGroupingSetsProjectMerge.
@Test
public void testAggregateGroupingSetsProjectMerge() {
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select x, sum(z), y from (\n" + " select deptno as x, empno as y, sal as z, sal * 2 as zz\n" + " from emp)\n" + "group by rollup(x, y)");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPullNull.
@Test
public void testPullNull() 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\n" + "and empno = 10 and mgr is null and empno = 10";
checkPlanning(program, sql);
}
Aggregations