use of org.apache.calcite.plan.hep.HepProgram 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);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctWithMultipleInputs.
@Test
public void testDistinctWithMultipleInputs() {
final String sql = "SELECT deptno, SUM(comm), MIN(comm), COUNT(DISTINCT sal, 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.HepProgram in project calcite by apache.
the class RelOptRulesTest method testMergeIntersect.
/**
* Tests {@link UnionMergeRule#INTERSECT_INSTANCE}, which merges 2
* {@link Intersect} operators into a single {@code Intersect} with 3
* inputs.
*/
@Test
public void testMergeIntersect() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(UnionMergeRule.INTERSECT_INSTANCE).build();
final String sql = "select * from emp where deptno = 10\n" + "intersect\n" + "select * from emp where deptno = 20\n" + "intersect\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 testAggregateProjectPullUpConstants.
@Test
public void testAggregateProjectPullUpConstants() {
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateProjectPullUpConstantsRule.INSTANCE2).build();
final String sql = "select job, empno, sal, sum(sal) as s\n" + "from emp where empno = 10\n" + "group by job, empno, sal";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSemiJoinRuleLeft.
/**
* Similar to {@link #testSemiJoinRule()} but LEFT.
*/
@Test
public void testSemiJoinRuleLeft() {
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 name from dept left join (\n" + " select distinct deptno from emp\n" + " where sal > 100) using (deptno)";
sql(sql).withPre(preProgram).with(program).withDecorrelation(true).withTrim(true).check();
}
Aggregations