use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSortUnionTranspose2.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-889">[CALCITE-889]
* Implement SortUnionTransposeRule</a>.
*/
@Test
public void testSortUnionTranspose2() {
final HepProgram program = HepProgram.builder().addRuleInstance(ProjectSetOpTransposeRule.INSTANCE).addRuleInstance(SortUnionTransposeRule.MATCH_NULL_FETCH).build();
final String sql = "select a.name from dept a\n" + "union all\n" + "select b.name from dept b\n" + "order by name";
checkPlanning(program, sql);
}
use of org.apache.calcite.plan.hep.HepProgram 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.HepProgram 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");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testMultipleDistinctWithGrouping.
@Test
public void testMultipleDistinctWithGrouping() {
final String sql = "SELECT sal, SUM(comm), MIN(DISTINCT comm), SUM(DISTINCT sal)\n" + "FROM emp\n" + "GROUP BY sal";
HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateExpandDistinctAggregatesRule.JOIN).build();
sql(sql).with(program).check();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testUnionMergeRule.
/**
* Tests to see if the final branch of union is missed
*/
@Test
public void testUnionMergeRule() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(ProjectSetOpTransposeRule.INSTANCE).addRuleInstance(ProjectRemoveRule.INSTANCE).addRuleInstance(UnionMergeRule.INSTANCE).build();
checkPlanning(program, "select * from (\n" + "select * from (\n" + " select name, deptno from dept\n" + " union all\n" + " select name, deptno from\n" + " (\n" + " select name, deptno, count(1) from dept group by name, deptno\n" + " union all\n" + " select name, deptno, count(1) from dept group by name, deptno\n" + " ) subq\n" + ") a\n" + "union all\n" + "select name, deptno from dept\n" + ") aa\n");
}
Aggregations