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);
}
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);
}
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);
}
Aggregations