use of org.apache.calcite.plan.volcano.PlannerTests.PhysSingleRel in project calcite by apache.
the class VolcanoPlannerTest method testTransformSingleReformed.
/**
* Tests transformation of a single+leaf from NONE to PHYS. In the past,
* this one didn't work due to the definition of ReformedSingleRule.
*/
// broken, because ReformedSingleRule matches child traits strictly
@Ignore
@Test
public void testTransformSingleReformed() {
VolcanoPlanner planner = new VolcanoPlanner();
planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
planner.addRule(new PhysLeafRule());
planner.addRule(new ReformedSingleRule());
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.PhysSingleRel in project calcite by apache.
the class VolcanoPlannerTest method testSubsetRule.
/**
* Tests a rule that is fired once per subset (whereas most rules are fired
* once per rel in a set or rel in a subset)
*/
@Test
public void testSubsetRule() {
VolcanoPlanner planner = new VolcanoPlanner();
planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
planner.addRule(new PhysLeafRule());
planner.addRule(new GoodSingleRule());
final List<String> buf = new ArrayList<>();
planner.addRule(new SubsetRule(buf));
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);
assertThat(sort(buf), equalTo(sort("NoneSingleRel:Subset#0.NONE", "PhysSingleRel:Subset#0.NONE", "PhysSingleRel:Subset#0.PHYS")));
}
use of org.apache.calcite.plan.volcano.PlannerTests.PhysSingleRel 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);
}
Aggregations