use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testEmptyAggregateEmptyKeyWithAggregateValuesRule.
@Test
public void testEmptyAggregateEmptyKeyWithAggregateValuesRule() {
HepProgram preProgram = HepProgram.builder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(PruneEmptyRules.PROJECT_INSTANCE).build();
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateValuesRule.INSTANCE).build();
final String sql = "select count(*), sum(empno) from emp where false";
sql(sql).withPre(preProgram).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testEmptyJoin.
@Test
public void testEmptyJoin() {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(PruneEmptyRules.PROJECT_INSTANCE).addRuleInstance(PruneEmptyRules.JOIN_LEFT_INSTANCE).addRuleInstance(PruneEmptyRules.JOIN_RIGHT_INSTANCE).build();
// Plan should be empty
checkPlanning(program, "select * from (\n" + "select * from emp where false)\n" + "join dept using (deptno)");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSemiJoinRuleExists.
@Test
public void testSemiJoinRuleExists() {
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 * from dept where exists (\n" + " select * from emp\n" + " where emp.deptno = dept.deptno\n" + " and emp.sal > 100)";
sql(sql).withDecorrelation(true).withTrim(true).withPre(preProgram).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testReduceConstantsNull.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1860">[CALCITE-1860]
* Duplicate null predicates cause NullPointerException in RexUtil</a>.
*/
@Test
public void testReduceConstantsNull() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
final String sql = "select * from (\n" + " select *\n" + " from (\n" + " select cast(null as integer) as n\n" + " from emp)\n" + " where n is null and n is null)\n" + "where n is null";
sql(sql).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram 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);
}
Aggregations