[ 
https://issues.apache.org/jira/browse/CALCITE-2291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16462526#comment-16462526
 ] 

Volodymyr Vysotskyi commented on CALCITE-2291:
----------------------------------------------

[~cshi], could you please add more tests for ProjectCorrelateTransposeRule. It 
would be great to test this rule for correlate with all join types. It may be 
done using similar tests (it creates left correlate):
{code:java}
  @Test public void testCorrelationProjectTransposeRule() {
    final String sql = "SELECT e1.empno, d1.deptno as deptno1\n"
        + "FROM emp e1, dept d1 where e1.deptno = d1.deptno\n"
        + "and exists (select empno, deptno from dept d2 where e1.deptno = 
d2.deptno)";
    HepProgram program = new HepProgramBuilder()
        .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
        .addRuleInstance(ProjectFilterTransposeRule.INSTANCE)
        .addRuleInstance(ProjectCorrelateTransposeRule.INSTANCE)
        .build();
    sql(sql)
        .withDecorrelation(false)
        .expand(true)
        .with(program)
        .check();
  }
{code}

To test correlate with other join types, a query should be modified as 
described in 
[SemiJoinType|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/SemiJoinType.java#L29].

Also original rel nodes may be constructed using RelBuilder, if it is hard to 
receive correlate with concrete join type for the test 
([testFilterRemoveIsNotDistinctFromRule|https://github.com/apache/calcite/blob/master/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java#L3830]
 may be used as an example).

> Add rule to push Project past Correlate
> ---------------------------------------
>
>                 Key: CALCITE-2291
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2291
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Chunhui Shi
>            Assignee: Julian Hyde
>            Priority: Major
>
> Correlate is not derived from Join so we need a rule similar to 
> ProjectJoinTransposeRule to push Project to under Correlate.



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

Reply via email to