use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctCountMixed2.
@Test
public void testDistinctCountMixed2() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE).addRuleInstance(AggregateProjectMergeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select deptno, count(distinct ename) as cde,\n" + " count(distinct job, ename) as cdje,\n" + " count(distinct deptno, job) as cddj,\n" + " sum(sal) as s\n" + " from sales.emp group by deptno");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testJoinProjectTranspose.
@Test
public void testJoinProjectTranspose() {
final HepProgram preProgram = HepProgram.builder().addRuleInstance(ProjectJoinTransposeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
final HepProgram program = HepProgram.builder().addRuleInstance(JoinProjectTransposeRule.LEFT_PROJECT_INCLUDE_OUTER).addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(JoinProjectTransposeRule.RIGHT_PROJECT_INCLUDE_OUTER).addRuleInstance(JoinProjectTransposeRule.LEFT_PROJECT_INCLUDE_OUTER).addRuleInstance(ProjectMergeRule.INSTANCE).build();
final String sql = "select a.name\n" + "from dept a\n" + "left join dept b on b.deptno > 10\n" + "right join dept c on b.deptno > 10\n";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPushFilterPastProject.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-448">[CALCITE-448]
* FilterIntoJoinRule creates filters containing invalid RexInputRef</a>.
*/
@Test
public void testPushFilterPastProject() {
final HepProgram preProgram = HepProgram.builder().addRuleInstance(ProjectMergeRule.INSTANCE).build();
final FilterJoinRule.Predicate predicate = new FilterJoinRule.Predicate() {
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
return joinType != JoinRelType.INNER;
}
};
final FilterJoinRule join = new FilterJoinRule.JoinConditionPushRule(RelBuilder.proto(), predicate);
final FilterJoinRule filterOnJoin = new FilterJoinRule.FilterIntoJoinRule(true, RelBuilder.proto(), predicate);
final HepProgram program = HepProgram.builder().addGroupBegin().addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(join).addRuleInstance(filterOnJoin).addGroupEnd().build();
final String sql = "select a.name\n" + "from dept a\n" + "left join dept b on b.deptno > 10\n" + "right join dept c on b.deptno > 10\n";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSemiJoinRuleRight.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1495">[CALCITE-1495]
* SemiJoinRule should not apply to RIGHT and FULL JOIN</a>.
*/
@Test
public void testSemiJoinRuleRight() {
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 dept.* from dept right join (\n" + " select distinct deptno from emp\n" + " where sal > 100) using (deptno)";
sql(sql).withPre(preProgram).with(program).withDecorrelation(true).withTrim(true).checkUnchanged();
}
use of org.apache.calcite.plan.hep.HepProgram 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}");
}
Aggregations