In fact, calcite's rule doesn't care about alias, so it may lose alias when
transforming.

Regards!

Aron Tao


Yanjing Wang <[email protected]> 于2021年11月24日周三 下午2:47写道:

> Hi, team
>   I'm using ProjectRemoveRule to simplify my logical plan, But the plan
> sometimes miss its project alias, I find the rule hasn't checked the alias
> for project row type identity equation, so I think it may be a bug, I have
> tried to reproduce the problem, but I failed to build two projects.
>
>   I have tried the following but the plan always ignores the alias:
>
> final Function<RelBuilder, RelNode> relFn = b -> {
>       RelNode plan = b.scan("EMP")
>           .project(
>               b.field("DEPTNO"),
>               b.field("ENAME")
>           )
>           .project(
>               b.alias(b.field(0), "DEPTNO_ALIAS"),
>               b.alias(b.field(1), "ENAME_ALIAS")
>           )
>           .build();
>       return plan;
>     };
>
> relFn(relFn)
>         .withRule(
>             CoreRules.PROJECT_REMOVE)
>         .withRelBuilderConfig(b -> b.withBloat(-1))
>         .check();
>
>
>   So I resort to modifying existing test case to reproduce, I change
> the testUnionMergeRule test case in RelOptRulesTest.java. I change its
> final projection *** to *name as ename, deptno as edeptno*,
> and the plan miss the alias again. I think the hep rules shouldn't remove
> the alias which are output column label.
>

Reply via email to