[CALCITE-3004] RexOver is incorrectly pushed down in ProjectSetOpTran…#1166
Conversation
| setOp.copy(setOp.getTraitSet(), newSetOpInputs); | ||
| node = pushProject.createNewProject(newSetOp, adjustments); | ||
| } else { | ||
| // push some expressions below the setop; this |
There was a problem hiding this comment.
There is if..else.. in that I don't want to change the plan of some cases. For instance, current plan of
select ename,avg(empno) from
(select * from emp as e1 union all select * from emp as e2)
is
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
LogicalUnion(all=[true])
LogicalProject(ENAME=[$1], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(ENAME=[$1], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
But if without if..else.., the plan becomes
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
LogicalProject(ENAME=[$1], EMPNO=[$0])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(EMPNO=[$0], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
which seems redundant.
| </TestCase> | ||
| <TestCase name="testProjectCorrelateTranspose"> | ||
| <TestCase name="testProjectCorrelateTransposeWithOver"> | ||
| <Resource name="sql"> |
There was a problem hiding this comment.
Note that testProjectCorrelateTranspose in RelOptRulesTest.xml is redundant[1][2].
[1] https://github.com/apache/calcite/blob/master/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml#L9226
[2] https://github.com/apache/calcite/blob/master/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml#L9253
There was a problem hiding this comment.
Ah. Somehow there's a duplicate key in RelOptRulesTest.xml. Maybe it's a merge error, I don't know. Can someone add code to DiffRepository to make it fail when reading a .xml file if there are duplicate keys.
|
@julianhyde @zhztheplayer, could you please review the PR? Thanks a lot. |
…sposeRule and ProjectCorrelateTransposeRule (Chunwei Lei)
995dbfe to
d166bdb
Compare
|
Updated for resolving conflicts. |
…sposeRule and ProjectCorrelateTransposeRule (Chunwei Lei)
JIRA: https://issues.apache.org/jira/browse/CALCITE-3004