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 13:11:00 UTC
[jira] [Updated] (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 updated CALCITE-2410:
-------------------------------------
Description:
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}
was:
Currently {{ProjectSetOpTransposeRule}} rule can transpose UnionAll SetOp and Project RelNodes. It disabled for Union (distinct) SetOp operator.
{code}
// 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.
> 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)