use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testAggregateConstantKeyRule2.
/**
* Tests {@link AggregateProjectPullUpConstantsRule} where reduction is not
* possible because "deptno" is the only key.
*/
@Test
public void testAggregateConstantKeyRule2() {
final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateProjectPullUpConstantsRule.INSTANCE2).build();
final String sql = "select count(*) as c\n" + "from sales.emp\n" + "where deptno = 10\n" + "group by deptno";
checkPlanUnchanged(new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testMergeUnionAll.
/**
* Tests {@link UnionMergeRule}, which merges 2 {@link Union} operators into
* a single {@code Union} with 3 inputs.
*/
@Test
public void testMergeUnionAll() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(UnionMergeRule.INSTANCE).build();
final String sql = "select * from emp where deptno = 10\n" + "union all\n" + "select * from emp where deptno = 20\n" + "union all\n" + "select * from emp where deptno = 30\n";
sql(sql).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPushFilterPastAggThree.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-799">[CALCITE-799]
* Incorrect result for {@code HAVING count(*) > 1}</a>.
*/
@Test
public void testPushFilterPastAggThree() {
final HepProgram program = HepProgram.builder().addRuleInstance(FilterAggregateTransposeRule.INSTANCE).build();
final String sql = "select deptno from emp\n" + "group by deptno having count(*) > 1";
checkPlanUnchanged(new HepPlanner(program), sql);
}
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);
}
Aggregations