use of org.apache.calcite.plan.hep.HepProgramBuilder 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.HepProgramBuilder 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.HepProgramBuilder 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();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method basePullConstantTroughAggregate.
private void basePullConstantTroughAggregate() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(AggregateProjectPullUpConstantsRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
checkPlanning(program, "${sql}");
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testReduceConstantsRequiresExecutor.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-566">[CALCITE-566]
* ReduceExpressionsRule requires planner to have an Executor</a>.
*/
@Test
public void testReduceConstantsRequiresExecutor() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).build();
// Remove the executor
tester.convertSqlToRel("values 1").rel.getCluster().getPlanner().setExecutor(null);
// Rule should not fire, but there should be no NPE
final String sql = "select * from (values (1,2)) where 1 + 2 > 3 + CAST(NULL AS INTEGER)";
checkPlanUnchanged(new HepPlanner(program), sql);
}
Aggregations