use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testEmptyJoinLeft.
@Test
public void testEmptyJoinLeft() {
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" + "left join dept using (deptno)");
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testReduceConstantsIsNotNull.
@Test
public void testReduceConstantsIsNotNull() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
final String sql = "select empno from emp\n" + "where empno=10 and empno is not null";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testSortProjectTranspose3.
@Test
public void testSortProjectTranspose3() {
final HepProgram program = new HepProgramBuilder().addRuleInstance(SortProjectTransposeRule.INSTANCE).build();
// This one cannot be pushed down
final String sql = "select d.deptno from sales.dept d\n" + "order by cast(d.deptno as varchar(10)) offset 1";
sql(sql).with(program).checkUnchanged();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testReduceNullableCase2.
@Test
public void testReduceNullableCase2() {
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE);
final String sql = "SELECT deptno, ename, CASE WHEN 1=2 " + "THEN substring(ename, 1, cast(2 as int)) ELSE NULL end from emp" + " group by deptno, ename, case when 1=2 then substring(ename,1, cast(2 as int)) else null end";
sql(sql).with(hepPlanner).check();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testRemoveSemiJoinRight.
@Test
public void testRemoveSemiJoinRight() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(JoinAddRedundantSemiJoinRule.INSTANCE).addRuleInstance(SemiJoinJoinTransposeRule.INSTANCE).addRuleInstance(SemiJoinRemoveRule.INSTANCE).build();
checkPlanning(program, "select e1.ename from emp e1, dept d, emp e2 " + "where e1.deptno = d.deptno and d.deptno = e2.deptno");
}
Aggregations