use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testReduceConstants.
@Test
public void testReduceConstants() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
// NOTE jvs 27-May-2006: among other things, this verifies
// intentionally different treatment for identical coalesce expression
// in select and where.
// There is "CAST(2 AS INTEGER)" in the plan because 2 has type "INTEGER NOT
// NULL" and we need "INTEGER".
final String sql = "select" + " 1+2, d.deptno+(3+4), (5+6)+d.deptno, cast(null as integer)," + " coalesce(2,null), row(7+8)" + " from dept d inner join emp e" + " on d.deptno = e.deptno + (5-5)" + " where d.deptno=(7+8) and d.deptno=(8+7) and d.deptno=coalesce(2,null)";
sql(sql).with(program).withProperty(Hook.REL_BUILDER_SIMPLIFY, false).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testProjectWindowTransposeRule.
@Test
public void testProjectWindowTransposeRule() {
HepProgram program = new HepProgramBuilder().addRuleInstance(ProjectToWindowRule.PROJECT).addRuleInstance(ProjectWindowTransposeRule.INSTANCE).build();
final String sql = "select count(empno) over(), deptno from emp";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testReduceExpressionsNot.
@Test
public void testReduceExpressionsNot() {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
checkPlanUnchanged(new HepPlanner(program), "select * from (values (false),(true)) as q (col1) where not(col1)");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPullConstantThroughUnion2.
@Test
public void testPullConstantThroughUnion2() throws Exception {
// Negative test: constants should not be pulled up
HepProgram program = HepProgram.builder().addRuleInstance(UnionPullUpConstantsRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
final String sql = "select 2, deptno, job from emp as e1\n" + "union all\n" + "select 1, deptno, job from emp as e2";
checkPlanUnchanged(new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctWithMultipleInputsAndGroupby.
@Test
public void testDistinctWithMultipleInputsAndGroupby() {
final String sql = "SELECT deptno, SUM(comm), MIN(comm), COUNT(DISTINCT sal, deptno, comm)\n" + "FROM emp\n" + "GROUP BY deptno";
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateExpandDistinctAggregatesRule.JOIN).build();
sql(sql).with(program).check();
}
Aggregations