use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSemiJoinRuleFull.
/**
* Similar to {@link #testSemiJoinRuleRight()} but FULL.
*/
@Test
public void testSemiJoinRuleFull() {
final HepProgram preProgram = HepProgram.builder().addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(ProjectMergeRule.INSTANCE).build();
final HepProgram program = HepProgram.builder().addRuleInstance(SemiJoinRule.PROJECT).build();
final String sql = "select dept.* from dept full join (\n" + " select distinct deptno from emp\n" + " where sal > 100) using (deptno)";
sql(sql).withPre(preProgram).with(program).withDecorrelation(true).withTrim(true).checkUnchanged();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctCountMultipleNoGroup.
@Test
public void testDistinctCountMultipleNoGroup() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE).addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select count(distinct ename), count(distinct job)\n" + " from sales.emp");
}
use of org.apache.calcite.plan.hep.HepProgram 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.HepProgram 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.HepProgram 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);
}
Aggregations