Search in sources :

Example 6 with NoneLeafRel

use of org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel in project calcite by apache.

the class ComboRuleTest method testCombo.

@Test
public void testCombo() {
    VolcanoPlanner planner = new VolcanoPlanner();
    planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
    planner.addRule(new ComboRule());
    planner.addRule(new AddIntermediateNodeRule());
    planner.addRule(new GoodSingleRule());
    RelOptCluster cluster = newCluster(planner);
    NoneLeafRel leafRel = new NoneLeafRel(cluster, "a");
    NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel);
    NoneSingleRel singleRel2 = new NoneSingleRel(cluster, singleRel);
    RelNode convertedRel = planner.changeTraits(singleRel2, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
    planner.setRoot(convertedRel);
    RelNode result = planner.chooseDelegate().findBestExp();
    assertTrue(result instanceof IntermediateNode);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) GoodSingleRule(org.apache.calcite.plan.volcano.PlannerTests.GoodSingleRule) RelNode(org.apache.calcite.rel.RelNode) NoneSingleRel(org.apache.calcite.plan.volcano.PlannerTests.NoneSingleRel) NoneLeafRel(org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel) Test(org.junit.Test)

Example 7 with NoneLeafRel

use of org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel in project calcite by apache.

the class VolcanoPlannerTest method testTransformSingleGood.

/**
 * Tests transformation of a single+leaf from NONE to PHYS.
 */
@Test
public void testTransformSingleGood() {
    VolcanoPlanner planner = new VolcanoPlanner();
    planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
    planner.addRule(new PhysLeafRule());
    planner.addRule(new GoodSingleRule());
    RelOptCluster cluster = newCluster(planner);
    NoneLeafRel leafRel = new NoneLeafRel(cluster, "a");
    NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel);
    RelNode convertedRel = planner.changeTraits(singleRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
    planner.setRoot(convertedRel);
    RelNode result = planner.chooseDelegate().findBestExp();
    assertTrue(result instanceof PhysSingleRel);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) GoodSingleRule(org.apache.calcite.plan.volcano.PlannerTests.GoodSingleRule) RelNode(org.apache.calcite.rel.RelNode) PhysLeafRule(org.apache.calcite.plan.volcano.PlannerTests.PhysLeafRule) NoneSingleRel(org.apache.calcite.plan.volcano.PlannerTests.NoneSingleRel) NoneLeafRel(org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel) PhysSingleRel(org.apache.calcite.plan.volcano.PlannerTests.PhysSingleRel) Test(org.junit.Test)

Example 8 with NoneLeafRel

use of org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel in project calcite by apache.

the class VolcanoPlannerTest method testRemoveSingleGood.

/**
 * This always worked (in contrast to testRemoveSingleReformed) because it
 * uses a completely-physical pattern (requiring GoodSingleRule to fire
 * first).
 */
@Test
public void testRemoveSingleGood() {
    VolcanoPlanner planner = new VolcanoPlanner();
    planner.ambitious = true;
    planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
    planner.addRule(new PhysLeafRule());
    planner.addRule(new GoodSingleRule());
    planner.addRule(new GoodRemoveSingleRule());
    RelOptCluster cluster = newCluster(planner);
    NoneLeafRel leafRel = new NoneLeafRel(cluster, "a");
    NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel);
    RelNode convertedRel = planner.changeTraits(singleRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
    planner.setRoot(convertedRel);
    RelNode result = planner.chooseDelegate().findBestExp();
    assertTrue(result instanceof PhysLeafRel);
    PhysLeafRel resultLeaf = (PhysLeafRel) result;
    assertEquals("c", resultLeaf.label);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) GoodSingleRule(org.apache.calcite.plan.volcano.PlannerTests.GoodSingleRule) RelNode(org.apache.calcite.rel.RelNode) PhysLeafRule(org.apache.calcite.plan.volcano.PlannerTests.PhysLeafRule) NoneSingleRel(org.apache.calcite.plan.volcano.PlannerTests.NoneSingleRel) NoneLeafRel(org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel) PhysLeafRel(org.apache.calcite.plan.volcano.PlannerTests.PhysLeafRel) Test(org.junit.Test)

Aggregations

RelOptCluster (org.apache.calcite.plan.RelOptCluster)8 NoneLeafRel (org.apache.calcite.plan.volcano.PlannerTests.NoneLeafRel)8 RelNode (org.apache.calcite.rel.RelNode)8 Test (org.junit.Test)8 PhysLeafRule (org.apache.calcite.plan.volcano.PlannerTests.PhysLeafRule)7 NoneSingleRel (org.apache.calcite.plan.volcano.PlannerTests.NoneSingleRel)6 GoodSingleRule (org.apache.calcite.plan.volcano.PlannerTests.GoodSingleRule)4 PhysLeafRel (org.apache.calcite.plan.volcano.PlannerTests.PhysLeafRel)4 PhysSingleRel (org.apache.calcite.plan.volcano.PlannerTests.PhysSingleRel)3 Ignore (org.junit.Ignore)3 ArrayList (java.util.ArrayList)1 RelOptListener (org.apache.calcite.plan.RelOptListener)1