You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2019/03/24 17:58:00 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16800131#comment-16800131 ]
Julian Hyde commented on CALCITE-2949:
--------------------------------------
I strongly believe that this should be fixed in a planner rule (or perhaps intelligence in RelBuilder), not in SqlToRelConverter. SqlToRelConverter is necessarily very complex just in order to accomplish its core task; we should not be making it more complex in order to perform optimizations.
So, someone please work on CALCITE-1172.
> 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)