rubenada commented on PR #4207:
URL: https://github.com/apache/calcite/pull/4207#issuecomment-2682400049
@xiedeyantu I understand the situation, in this case it seems we need to
"force" a bit the scenario, but as a rule of thumb we really demand (generally)
a unit test "showing" the issue together with the fix. IIANM using a HepPlanner
with noDag=true avoids the refactoring that is "blocking" your test, could you
please verify if the following test (to be added in RelOptRulesTest.java):
```
@Test void testProjectRemoveRule() {
final Function<RelBuilder, RelNode> relFn = b -> {
RelNode r = b.scan("DEPT")
.project(b.call(SqlStdOperatorTable.PLUS,
ImmutableList.of(b.field(0), b.literal(1))))
.build();
b.push(r);
return LogicalProject.create(r, ImmutableList.of(),
ImmutableList.of(b.field(0)), ImmutableList.of("newAlias"), ImmutableSet.of());
};
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleInstance(CoreRules.PROJECT_REMOVE);
HepPlanner planner = new HepPlanner(builder.build(), null, true, null,
RelOptCostImpl.FACTORY);
fixture().withRelBuilderConfig(a -> a.withBloat(-1))
.relFn(relFn).withPlanner(planner).check();
}
```
Together with this new context in RelOptRulesTest.xml (notice it must be
added in alphabetical order by test name)
```
<TestCase name="testProjectRemoveRule">
<Resource name="planBefore">
<![CDATA[
LogicalProject(newAlias=[$0])
LogicalProject($f0=[+($0, 1)])
LogicalTableScan(table=[[scott, DEPT]])
]]>
</Resource>
<Resource name="planAfter">
<![CDATA[
LogicalProject(newAlias=[+($0, 1)])
LogicalTableScan(table=[[scott, DEPT]])
]]>
</Resource>
</TestCase>
```
Fails on the current code, but passes with your patch? Thanks
--
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]