Hello, This topic was discussed in https://issues.apache.org/jira/browse/CALCITE-1584.
I am sure if Calcite does it, but in another SQL parser/analyzer implementation I have saw, each logical plan has a top attribute about final output column names, so even nodes might be merged/removed, at least there are still output column names that we can get. -Rui On Wed, May 27, 2020 at 5:38 AM 董 一峰 <donga...@outlook.com> wrote: > Hello everyone, > > When we run the following test case: > SQL: > WITH T_CTE (i1_cte, i2_cte) AS ( > SELECT > i1, > d3 > FROM > t1 > ) > SELECT > * > FROM > t2 > JOIN T_CTE ON (t2.i1 = T_CTE.i1_cte) > > > Logical Plan(After ProjectRemoveRule): > LogicalJoin(condition=[=($0, $14)], joinType=[inner]) > :- LogicalTableScan(table=[[default, db1, t2]]) > +- LogicalCalc(expr#0..13=[{inputs}], i1=[$t0], d3=[$t2]) > +- LogicalTableScan(table=[[default, db1, t1]]) > > > We wish the output column name contain i1_cte, i2_cte, but calcite just > drop it. > After analysisinp the calcite code, we found the rule named > ProjectRemoveRule, it will remove the project if project and its input has > same size and type, but it confused me, why this rule dose not consider the > field name when remove project? > > Best Regards > Axis > >