Description
Currently ProjectSetOpTransposeRule rule can transpose UnionAll SetOp and Project RelNodes. It disabled for Union (distinct) SetOp operator.
// cannot push project past a distinct if (!setOp.all) { return; }
After removing this check the rule works fineĀ and transposesĀ Union (distinct) SetOp and Project RelNodes.
Test case for reproduce (RelOptRulesTest class):
@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>
Attachments
Issue Links
- is related to
-
DRILL-6417 Project is not pushed into scan if use subquery with UNION operator
- Closed