use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctCountMultiple.
/**
* Tests implementing multiple distinct count the new way, using GROUPING
* SETS.
*/
@Test
public void testDistinctCountMultiple() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE).addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select deptno, count(distinct ename), count(distinct job)\n" + " from sales.emp group by deptno");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testWindowFunctionOnAggregations.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-2078">[CALCITE-2078]
* Aggregate functions in OVER clause</a>.
*/
@Test
public void testWindowFunctionOnAggregations() {
final HepProgram program = HepProgram.builder().addRuleInstance(ProjectToWindowRule.PROJECT).build();
final String sql = "SELECT\n" + " min(empno),\n" + " sum(sal),\n" + " sum(sum(sal))\n" + " over (partition by min(empno) order by sum(sal))\n" + "from emp\n" + "group by deptno";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testRemoveSemiJoinRight.
@Test
public void testRemoveSemiJoinRight() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(JoinAddRedundantSemiJoinRule.INSTANCE).addRuleInstance(SemiJoinJoinTransposeRule.INSTANCE).addRuleInstance(SemiJoinRemoveRule.INSTANCE).build();
checkPlanning(program, "select e1.ename from emp e1, dept d, emp e2 " + "where e1.deptno = d.deptno and d.deptno = e2.deptno");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctCountMultipleViaJoin.
/**
* Tests implementing multiple distinct count the old way, using a join.
*/
@Test
public void testDistinctCountMultipleViaJoin() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateExpandDistinctAggregatesRule.JOIN).addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select deptno, count(distinct ename), count(distinct job, ename),\n" + " count(distinct deptno, job), sum(sal)\n" + " from sales.emp group by deptno");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testPullConstantThroughUnion3.
@Test
public void testPullConstantThroughUnion3() throws Exception {
// We should leave at least a single column in each Union input
HepProgram program = HepProgram.builder().addRuleInstance(UnionPullUpConstantsRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
final String sql = "select 2, 3 from emp as e1\n" + "union all\n" + "select 2, 3 from emp as e2";
sql(sql).withTrim(true).with(program).check();
}
Aggregations