Xurenhe created CALCITE-4982: -------------------------------- Summary: NoNull filed is pushed down into right of full-join in 'ProjectJoinTransposeRule' Key: CALCITE-4982 URL: https://issues.apache.org/jira/browse/CALCITE-4982 Project: Calcite Issue Type: Bug Reporter: Xurenhe Assignee: Xurenhe
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. {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.1#820001)