Search in sources :

Example 76 with HepProgram

use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.

the class RelOptRulesTest method testSortUnionTranspose3.

/**
 * Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-987">[CALCITE-987]
 * Push limit 0 will result in an infinite loop</a>.
 */
@Test
public void testSortUnionTranspose3() {
    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 limit 0";
    checkPlanning(program, sql);
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) Test(org.junit.Test)

Example 77 with HepProgram

use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.

the class RelOptRulesTest method testPushAggregateSumThroughJoin.

/**
 * SUM is the easiest aggregate function to split.
 */
@Test
public void testPushAggregateSumThroughJoin() {
    final HepProgram preProgram = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
    final HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateJoinTransposeRule.EXTENDED).build();
    final String sql = "select e.job,sum(sal)\n" + "from (select * from sales.emp where empno = 10) as e\n" + "join sales.dept as d on e.job = d.name\n" + "group by e.job,d.name";
    checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) Test(org.junit.Test)

Example 78 with HepProgram

use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.

the class RelOptRulesTest method basePushAggThroughUnion.

private void basePushAggThroughUnion() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ProjectSetOpTransposeRule.INSTANCE).addRuleInstance(ProjectMergeRule.INSTANCE).addRuleInstance(AggregateUnionTransposeRule.INSTANCE).build();
    checkPlanning(program, "${sql}");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder)

Example 79 with HepProgram

use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.

the class RelOptRulesTest method testAggregateGroupingSetsProjectMerge.

@Test
public void testAggregateGroupingSetsProjectMerge() {
    HepProgram program = new HepProgramBuilder().addRuleInstance(AggregateProjectMergeRule.INSTANCE).build();
    checkPlanning(program, "select x, sum(z), y from (\n" + "  select deptno as x, empno as y, sal as z, sal * 2 as zz\n" + "  from emp)\n" + "group by rollup(x, y)");
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Example 80 with HepProgram

use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.

the class RelOptRulesTest method testPullNull.

@Test
public void testPullNull() throws Exception {
    HepProgram program = new HepProgramBuilder().addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE).addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE).addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
    final String sql = "select *\n" + "from emp\n" + "where deptno=7\n" + "and empno = 10 and mgr is null and empno = 10";
    checkPlanning(program, sql);
}
Also used : HepProgram(org.apache.calcite.plan.hep.HepProgram) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Test(org.junit.Test)

Aggregations

HepProgram (org.apache.calcite.plan.hep.HepProgram)190 Test (org.junit.Test)171 HepProgramBuilder (org.apache.calcite.plan.hep.HepProgramBuilder)142 HepPlanner (org.apache.calcite.plan.hep.HepPlanner)55 RelNode (org.apache.calcite.rel.RelNode)9 AggregateExtractProjectRule (org.apache.calcite.rel.rules.AggregateExtractProjectRule)4 RelBuilderFactory (org.apache.calcite.tools.RelBuilderFactory)4 Ignore (org.junit.Ignore)4 ImmutableList (com.google.common.collect.ImmutableList)3 List (java.util.List)3 Context (org.apache.calcite.plan.Context)3 RelDataType (org.apache.calcite.rel.type.RelDataType)3 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)3 Properties (java.util.Properties)2 CalciteConnectionConfigImpl (org.apache.calcite.config.CalciteConnectionConfigImpl)2 Project (org.apache.calcite.rel.core.Project)2 LogicalProject (org.apache.calcite.rel.logical.LogicalProject)2 FilterJoinRule (org.apache.calcite.rel.rules.FilterJoinRule)2 RelBuilder (org.apache.calcite.tools.RelBuilder)2 ImmutableMap (com.google.common.collect.ImmutableMap)1