xiedeyantu commented on PR #4399:
URL: https://github.com/apache/calcite/pull/4399#issuecomment-2918533700
In PlannerTest, we can freely set the rule set of hep planner and volcano
planner by writing the following. So this PR does not need to be continued, I
will close it.
```
@Test void testPlanTransform() throws Exception {
// Create two dummy rules with identical rules.
RelOptRule rule1 = MyProjectFilterRule.config("MYRULE").toRule();
RelOptRule rule2 = MyFilterProjectRule.config("MYRULE").toRule();
RuleSet ruleSet1 =
RuleSets.ofList(rule1,
EnumerableRules.ENUMERABLE_TABLE_SCAN_RULE,
EnumerableRules.ENUMERABLE_FILTER_RULE,
EnumerableRules.ENUMERABLE_PROJECT_RULE);
RuleSet ruleSet2 = RuleSets.ofList(rule2);
Planner planner =
getPlanner(null,
// using hep program
Programs.hep(ruleSet1, true,
DefaultRelMetadataProvider.INSTANCE),
// using volcano program
Programs.of(ruleSet2));
SqlNode parse = planner.parse("select * from \"emps\"");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
RelTraitSet traitSet = convert.getTraitSet()
.replace(EnumerableConvention.INSTANCE);
// This can do optimize in hep planner with ruleSet1
RelNode transform = planner.transform(0, traitSet, convert);
// This can do optimize in volcano planner with ruleSet2
RelNode transform2 = planner.transform(1, traitSet, transform);
assertThat(toString(transform2),
equalTo(
"EnumerableProject(empid=[$0], deptno=[$1], name=[$2],
salary=[$3], commission=[$4])\n"
+ " EnumerableTableScan(table=[[hr, emps]])\n"));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]