use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctCountMixed.
@Test
public void testDistinctCountMixed() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).build();
checkPlanning(program, "select deptno, count(distinct deptno, job) as cddj, 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 testCastInAggregateReduceFunctions.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1621">[CALCITE-1621]
* Adding a cast around the null literal in aggregate rules</a>.
*/
@Test
public void testCastInAggregateReduceFunctions() {
final HepProgram program = HepProgram.builder().addRuleInstance(AggregateReduceFunctionsRule.INSTANCE).build();
final String sql = "select name, stddev_pop(deptno), avg(deptno)," + " stddev_samp(deptno),var_pop(deptno), var_samp(deptno)\n" + "from sales.dept group by name";
sql(sql).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method checkReduceNullableToNotNull.
private void checkReduceNullableToNotNull(ReduceExpressionsRule rule) {
HepProgram program = new HepProgramBuilder().addRuleInstance(rule).build();
final String sql = "select\n" + " empno + case when 'a' = 'a' then 1 else null 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 testPushAggregateThroughJoinDistinct.
/**
* Push a aggregate functions into a relation that is unique on the join
* key.
*/
@Test
public void testPushAggregateThroughJoinDistinct() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
final String sql = "select d.name,\n" + " sum(sal) as sum_sal, count(*) as c\n" + "from sales.emp as e\n" + "join (select distinct name from sales.dept) as d\n" + " on e.job = d.name\n" + "group by 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 testReduceValuesUnderProjectFilter.
@Test
public void testReduceValuesUnderProjectFilter() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(ValuesReduceRule.PROJECT_FILTER_INSTANCE).build();
// Plan should be same as for
// select * from (values (11, 1, 10), (23, 3, 20)) as t(x, b, a)");
checkPlanning(program, "select a + b as x, b, a from (values (10, 1), (30, 7), (20, 3)) as t(a, b)" + " where a - b < 21");
}
Aggregations