use of org.apache.calcite.plan.hep.HepProgramBuilder 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.HepProgramBuilder 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.HepProgramBuilder 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);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testSortJoinTranspose6.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1507">[CALCITE-1507]
* OFFSET cannot be pushed through a JOIN if the non-preserved side of outer
* join is not count-preserving</a>.
*/
@Test
public void testSortJoinTranspose6() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(SortProjectTransposeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(SortJoinTransposeRule.INSTANCE).build();
// This one can be pushed down even if it has an OFFSET, since the dept
// table is count-preserving against the join condition.
final String sql = "select d.deptno, empno from sales.dept d\n" + "right join sales.emp e using (deptno) limit 10 offset 2";
sql(sql).withPre(preProgram).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testEmptyFilterProjectUnion.
@Test
public void testEmptyFilterProjectUnion() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterSetOpTransposeRule.INSTANCE).addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(ValuesReduceRule.PROJECT_FILTER_INSTANCE).addRuleInstance(PruneEmptyRules.PROJECT_INSTANCE).addRuleInstance(PruneEmptyRules.UNION_INSTANCE).build();
// Plan should be same as for
// select * from (values (30, 3)) as t(x, y)");
checkPlanning(program, "select * from (\n" + "select * from (values (10, 1), (30, 3)) as t (x, y)\n" + "union all\n" + "select * from (values (20, 2))\n" + ")\n" + "where x + y > 30");
}
Aggregations