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

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

Austin Haas created CALCITE-2143:
------------------------------------

             Summary: 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


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)