use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPushAggregateSumThroughJoinAfterAggregateReduce.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-2108">[CALCITE-2108]
* AggregateJoinTransposeRule incorrectly splits a SUM0 call when Aggregate
* has no group keys</a>.
*
* <p>Similar to {@link #testPushAggregateSumThroughJoin()},
* but also uses {@link AggregateReduceFunctionsRule}.
*/
@Test
public void testPushAggregateSumThroughJoinAfterAggregateReduce() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateReduceFunctionsRule.INSTANCE).addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
final String sql = "select sum(sal)\n" + "from (select * from sales.emp where empno = 10) as e\n" + "join sales.dept as d on e.job = d.name";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testReduceCase.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1439">[CALCITE-1439]
* Handling errors during constant reduction</a>.
*/
@Test
public void testReduceCase() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).build();
final String sql = "select\n" + " case when false then cast(2.1 as float)\n" + " else cast(1 as integer) end as newcol\n" + "from emp";
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 testEmptyJoinRight.
@Test
public void testEmptyJoinRight() {
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 equivalent to "select * from emp join dept".
// Cannot optimize away the join because of RIGHT.
checkPlanning(program, "select * from (\n" + "select * from emp where false)\n" + "right join dept using (deptno)");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPushSemiJoinPastFilter.
@Test
public void testPushSemiJoinPastFilter() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(JoinAddRedundantSemiJoinRule.INSTANCE).addRuleInstance(SemiJoinFilterTransposeRule.INSTANCE).build();
checkPlanning(program, "select e.ename from emp e, dept d " + "where e.deptno = d.deptno and e.ename = 'foo'");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSemiJoinReduceConstants.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-571">[CALCITE-571]
* ReduceExpressionsRule tries to reduce SemiJoin condition to non-equi
* condition</a>.
*/
@Test
public void testSemiJoinReduceConstants() {
final HepProgram preProgram = HepProgram.builder().addRuleInstance(SemiJoinRule.PROJECT).build();
final HepProgram program = HepProgram.builder().addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
final String sql = "select e1.sal\n" + "from (select * from emp where deptno = 200) as e1\n" + "where e1.deptno in (\n" + " select e2.deptno from emp e2 where e2.sal = 100)";
sql(sql).withDecorrelation(false).withTrim(true).withPre(preProgram).with(program).checkUnchanged();
}
Aggregations