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

[jira] [Resolved] (CALCITE-2410) Enable ProjectSetOpTransposeRule for UNION (distinct) SetOp operator

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

Vitalii Diravka resolved CALCITE-2410.
--------------------------------------
       Resolution: Won't Fix
    Fix Version/s:     (was: 1.17.0)

It looks like it is forbidden to transpose Project operator and SetOp operators, which do filtering. 
Since after applying new Project operators to the Scan operators in the result the different number of rows can be obtained.
That's why only UnionAll SetOp operator can be used for this rule.

Closed as "Not An Issue".

> Enable ProjectSetOpTransposeRule for UNION (distinct) SetOp operator
> --------------------------------------------------------------------
>
>                 Key: CALCITE-2410
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2410
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.16.0
>            Reporter: Vitalii Diravka
>            Assignee: Vitalii Diravka
>            Priority: Major
>
> Currently {{ProjectSetOpTransposeRule}} rule can transpose UnionAll SetOp and Project RelNodes. It disabled for Union (distinct) SetOp operator.
> {code:java}
> // cannot push project past a distinct
> if (!setOp.all) {
>  return;
> }
> {code}
> After removing this check the rule works fineĀ and transposesĀ Union (distinct) SetOp and Project RelNodes.
> Test case for reproduce (RelOptRulesTest class):
> {code}
> @Test public void testPushProjectPastUnionDistinct() {
>  checkPlanning(ProjectSetOpTransposeRule.INSTANCE,
>  "select sal from "
>  + "(select * from emp e1 union select * from emp e2)");
> }
>     <TestCase name="testPushProjectPastUnionDistinct">
>       <Resource name="sql">
>         <![CDATA[select sal from (select * from emp e1 union all select * from emp e2)]]>
>       </Resource>
>       <Resource name="planBefore">
>         <![CDATA[
> LogicalProject(SAL=[$5])
>   LogicalUnion(all=[false])
>     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
>       </Resource>
>       <Resource name="planAfter">
>         <![CDATA[
> LogicalUnion(all=[false])
>   LogicalProject(SAL=[$5])
>     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>   LogicalProject(SAL=[$5])
>     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
>       </Resource>
>     </TestCase>
> {code}



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