Zhen Chen created CALCITE-6864:
----------------------------------
Summary: ProjectAggregateMergeRule will lose the alias of the top
Project
Key: CALCITE-6864
URL: https://issues.apache.org/jira/browse/CALCITE-6864
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.39.0
Reporter: Zhen Chen
Assignee: Zhen Chen
Fix For: 1.39.0
SQL
{code:java}
select deptno + ss
from (
select job, deptno, min(sal) as ms, sum(sal) as ss
from sales.emp
group by job, deptno {code}
planBefore
{code:java}
LogicalProject(EXPR$0=[+($1, $3)])
LogicalAggregate(group=[{0, 1}], MS=[MIN($2)], SS=[SUM($2)])
LogicalProject(JOB=[$2], DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
planAfter(old)
{code:java}
LogicalProject($f0=[+($1, $2)])
LogicalAggregate(group=[{0, 1}], SS=[SUM($2)])
LogicalProject(JOB=[$2], DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
We should get like this
{code:java}
LogicalProject(EXPR$0=[+($1, $2)])
LogicalAggregate(group=[{0, 1}], SS=[SUM($2)])
LogicalProject(JOB=[$2], DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
We should keep the alias EXPR$0.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)