You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Samuel Waggoner (JIRA)" <ji...@apache.org> on 2018/01/20 00:57:00 UTC

[jira] [Commented] (CALCITE-2143) RelToSqlConverter produces incorrect SQL with aggregation

    [ https://issues.apache.org/jira/browse/CALCITE-2143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16333073#comment-16333073 ] 

Samuel Waggoner commented on CALCITE-2143:
------------------------------------------

I believe the problem is here:
[https://insight.io/github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java?line=949]

I'm working on a PR now.

> RelToSqlConverter produces incorrect SQL with aggregation
> ---------------------------------------------------------
>
>                 Key: CALCITE-2143
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2143
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.15.0
>            Reporter: Austin Haas
>            Assignee: Julian Hyde
>            Priority: Major
>
> This plan:
> {code:java}
> LogicalAggregate(group=[{1}], my-alias=[SUM($0)])
>   LogicalAggregate(group=[{0, 1}])
>     LogicalProject(b=[$2], a=[$0])
>       LogicalJoin(condition=[=($0, $1)], joinType=[inner])
>         LogicalTableScan(table=[[rel-1]])
>         LogicalTableScan(table=[[rel-2]]){code}
> Produces this erroneous SQL:
> {code:sql}
> SELECT `t0`.`my-alias` AS `a`, (SUM(`t0`.`a`)) AS `my-alias`
> FROM (SELECT `rel-2`.`b`, `rel-1`.`a`
>       FROM `rel-1`
>       INNER JOIN `rel-2` ON (`rel-1`.`a` = `rel-2`.`a`)
>       GROUP BY `rel-2`.`b`, `rel-1`.`a`) AS `t0`
> GROUP BY `t0`.`my-alias`{code}
> Note the first field of the outer SELECT, where 'my-alias' is aliased as 'a'.
> Any clues how to fix would be appreciated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)