You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Haisheng Yuan (JIRA)" <ji...@apache.org> on 2019/03/24 18:12:00 UTC

[jira] [Closed] (CALCITE-2949) Double aggregate generated for in subquery with distinct

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

Haisheng Yuan closed CALCITE-2949.
----------------------------------
    Resolution: Fixed

> Double aggregate generated for in subquery with distinct
> --------------------------------------------------------
>
>                 Key: CALCITE-2949
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2949
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Haisheng Yuan
>            Priority: Major
>
> Repro:
> Add the following test to SqlToRelConverterTest.java.
> {code:java}
> @Test public void testSubQueryIN() {
>     final String sql = "select deptno\n"
>         + "from EMP e\n"
>         + "where deptno in (select distinct deptno\n"
>         + "from EMP where empno=e.empno)";
>     sql(sql).ok();
>   }
> {code}
> Plan:
> {code:java}
> LogicalProject(DEPTNO=[$7])
>   LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
>     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalAggregate(group=[{0, 1}])
>       LogicalProject(DEPTNO=[$0], EMPNO=[$1])
>         LogicalAggregate(group=[{0, 1}])
>           LogicalProject(DEPTNO=[$7], EMPNO=[$0])
>             LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> One LogicalAggregate would suffice. Although the 2 aggregates can be merged by rules described in issue [CALCITE-1172|https://issues.apache.org/jira/browse/CALCITE-1172], which is not available yet.



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