You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Benchao Li (Jira)" <ji...@apache.org> on 2022/10/23 02:35:00 UTC

[jira] [Comment Edited] (CALCITE-4982) NonNull field shouldn't be pushed down into leaf of outer-join in 'ProjectJoinTransposeRule'

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

Benchao Li edited comment on CALCITE-4982 at 10/23/22 2:34 AM:
---------------------------------------------------------------

[~wojustme] Thanks for the update. I agree that some expressions/operators should not be pushed down. As discussed in CALCITE-5315 and CALCITE-2450, {{CASE}} should be one of them. For this case, maybe the right way is to not allow push {{{}CASE{}}}'s operand expressions partially down. WDYT?


was (Author: libenchao):
[~wojustme] Thanks for the update. I agree that some expressions/operators should not be pushed down. As discussed in CALCITE-5315 and CALCITE-2450, {{CASE}} should be only of them. For this case, maybe the right way is to not allow push {{CASE}}'s operand expressions partially down. WDYT?

> NonNull field shouldn't be pushed down into leaf of outer-join in 'ProjectJoinTransposeRule'
> --------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4982
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4982
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Xurenhe
>            Assignee: Xurenhe
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> I meet a bug, when applying rule of 'ProjectJoinTransposeRule'.
> Test Case:
> {code:java}
> @Test void testPushProjectPastLeftJoin2() {
>   final String sql = "select coalesce(d.name, b.job, '')\n"
>       + "from emp e\n"
>       + "left join bonus b on e.ename = b.ename\n"
>       + "left join dept d on e.deptno = d.deptno";
>   sql(sql).withRule(CoreRules.PROJECT_JOIN_TRANSPOSE).check();
> } {code}
> Exception Stack:
> {code:java}
> Suppressed: java.lang.AssertionError: Cannot add expression of different type to set:
> set type is RecordType(INTEGER NOT NULL DEPTNO, BOOLEAN NOT NULL EXPR$0, VARCHAR(10) NOT NULL EXPR$1) NOT NULL
> expression type is RecordType(INTEGER NOT NULL DEPTNO, BOOLEAN NOT NULL EXPR$0, VARCHAR(10) EXPR$1) NOT NULL
> set is rel#20:LogicalProject.(input=HepRelVertex#14,exprs=[$7, IS NOT NULL($10), CAST($10):VARCHAR(10) NOT NULL])
> expression is LogicalProject(DEPTNO=[$1], EXPR$0=[IS NOT NULL($3)], EXPR$1=[$4])
>   LogicalJoin(condition=[=($0, $2)], joinType=[left])
>     LogicalProject(ENAME=[$1], DEPTNO=[$7])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalProject(ENAME=[$0], JOB=[$1], EXPR$1=[$1])
>       LogicalTableScan(table=[[CATALOG, SALES, BONUS]]) {code}
> I found that right with wrap not-null shouldn't be push down in one stage.
>  
> {code:java}
> // before applying rule
> LogicalProject(DEPTNO=[$7], EXPR$0=[IS NOT NULL($10)], EXPR$1=[CAST($10):VARCHAR(10) NOT NULL])
>   LogicalJoin(condition=[=($1, $9)], joinType=[left])
>     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
> // after applying rule
> LogicalProject(DEPTNO=[$1], EXPR$0=[IS NOT NULL($3)], EXPR$1=[$4])
>   LogicalJoin(condition=[=($0, $2)], joinType=[left])
>     LogicalProject(ENAME=[$1], DEPTNO=[$7])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalProject(ENAME=[$0], JOB=[$1], EXPR$1=[$1])
>       LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
>  {code}
> `EXPR$1=[CAST($10):VARCHAR(10) NOT NULL]` should be pushed down, because of left-join.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)