[ 
https://issues.apache.org/jira/browse/CALCITE-3662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lei Jiang reassigned CALCITE-3662:
----------------------------------

    Assignee:     (was: Lei Jiang)

> Generate wrong SQL when plan contains Project(Sort(Aggregate)) and aggregate 
> 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
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: next
>
>          Time Spent: 6h
>  Remaining Estimate: 0h
>
> 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)

Reply via email to