use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testSortJoinTranspose3.
@Test
public void testSortJoinTranspose3() {
final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(SortProjectTransposeRule.INSTANCE).build();
final HepProgram program = new HepProgramBuilder().addRuleInstance(SortJoinTransposeRule.INSTANCE).build();
// This one cannot be pushed down
final String sql = "select * from sales.emp left join (\n" + "select * from sales.dept) using (deptno)\n" + "order by sal, name limit 10";
checkPlanning(tester, preProgram, new HepPlanner(program), sql, true);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testReduceNot.
@Test
public void testReduceNot() {
HepProgram preProgram = new HepProgramBuilder().build();
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.FILTER_INSTANCE);
final String sql = "select *\n" + "from (select (case when sal > 1000 then null else false end) as caseCol from emp)\n" + "where NOT(caseCol)";
checkPlanning(tester, preProgram, hepPlanner, sql, true);
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testDistinctNonDistinctTwoAggregatesWithGrouping.
@Test
public void testDistinctNonDistinctTwoAggregatesWithGrouping() {
final String sql = "SELECT deptno, SUM(comm), MIN(comm), SUM(DISTINCT sal)\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.HepProgram in project calcite by apache.
the class RelOptRulesTest method testEmptySort.
@Test
public void testEmptySort() {
HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(PruneEmptyRules.SORT_INSTANCE).build();
checkPlanning(program, "select * from emp where false order by deptno");
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelOptRulesTest method testIntersectToDistinct.
/**
* Tests {@link org.apache.calcite.rel.rules.IntersectToDistinctRule},
* which rewrites an {@link Intersect} operator with 3 inputs.
*/
@Test
public void testIntersectToDistinct() throws Exception {
HepProgram program = new HepProgramBuilder().addRuleInstance(UnionMergeRule.INTERSECT_INSTANCE).addRuleInstance(IntersectToDistinctRule.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();
}
Aggregations