[ https://issues.apache.org/jira/browse/CALCITE-3935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17085701#comment-17085701 ]
Jin Xing edited comment on CALCITE-3935 at 4/17/20, 12:37 PM: -------------------------------------------------------------- Thanks for reporting ! Seems the check in [1] is too strict, we should allow compensating Calc from the left child node when LEFT JOIN in JoinOnLeftCalcToJoinUnifyRule. BTW I think the issue can also happen in JoinOnRightCalcToJoinUnifyRule [[1] https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L1204|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L1204] was (Author: jinxing6...@126.com): Seems the check in [1] is too strict, we should allow compensating Calc from the left child node when LEFT JOIN in JoinOnLeftCalcToJoinUnifyRule. BTW I think the issue can also happen in JoinOnRightCalcToJoinUnifyRule [[1] https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L1204|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L1204] > Materialization-Failed, when querying with LeftJoinWithFilter > ------------------------------------------------------------- > > Key: CALCITE-3935 > URL: https://issues.apache.org/jira/browse/CALCITE-3935 > Project: Calcite > Issue Type: Bug > Reporter: Xurenhe > Priority: Major > Attachments: Jietu20200417-200532.png > > > {code:java} > @Test public void testJoinOnLeftProjectWithFilterToJoin() { > String mv = "" > + "select \"emps\".\"empid\", \"depts\".\"name\", > \"emps\".\"salary\"\n" + > "from \"emps\"\n" + > "left join \"depts\"\n" + > "on \"emps\".\"deptno\" = \"depts\".\"deptno\"\n" > + "where \"emps\".\"empid\" > 10"; > String query = "" > + "select \"emps\".\"empid\", \"depts\".\"name\", > \"emps\".\"salary\"\n" + > "from \"emps\"\n" + > "left join \"depts\"\n" + > "on \"emps\".\"deptno\" = \"depts\".\"deptno\"\n" > + "where \"emps\".\"empid\" > 40"; > sql(mv, query).withOnlyBySubstitution(true).ok(); > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)