[
https://issues.apache.org/jira/browse/CALCITE-2410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Volodymyr Vysotskyi updated CALCITE-2410:
-----------------------------------------
Fix Version/s: 1.17.0
> 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
> Fix For: 1.17.0
>
>
> 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)