Lei Jiang created CALCITE-3662: ---------------------------------- Summary: Generate wrong SQL when plan contains Project(Sort(Aggregate)) and aggreagated field has no alias Key: CALCITE-3662 URL: https://issues.apache.org/jira/browse/CALCITE-3662 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.21.0 Reporter: Lei Jiang Assignee: Lei Jiang Fix For: next
Input SQL: {code:java} select sum(sal) from scott.emp group by ename limit 10 {code} Optimized Plan: {code:java} JdbcToEnumerableConverter JdbcProject(EXPR$0=[$1]) JdbcSort(fetch=[10]) JdbcAggregate(group=[{1}], EXPR$0=[SUM($5)]) JdbcTableScan(table=[[SCOTT, EMP]]) {code} Output wrong SQL: outter select list is wrong. {code:java} SELECT SUM("SAL") FROM (SELECT "ENAME", SUM("SAL") FROM "SCOTT"."EMP" GROUP BY "ENAME" LIMIT 10) AS "t0" {code} It should be: {code:java} SELECT SUM("SAL") FROM "SCOTT"."EMP" GROUP BY "ENAME" LIMIT 10 {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)