use of org.apache.calcite.plan.hep.HepProgramBuilder 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.HepProgramBuilder 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.HepProgramBuilder 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.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testPullAggregateThroughUnion.
@Test
public void testPullAggregateThroughUnion() {
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateUnionAggregateRule.INSTANCE).build();
final String sql = "select deptno, job from" + " (select deptno, job from emp as e1" + " group by deptno,job" + " union all" + " select deptno, job from emp as e2" + " group by deptno,job)" + " group by deptno,job";
sql(sql).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class RelOptRulesTest method testReduceConstantsNullEqualsOne.
// see HIVE-9645
@Test
public void testReduceConstantsNullEqualsOne() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
checkPlanning(program, "select count(1) from emp where cast(null as integer) = 1");
}
Aggregations