hanyuzheng7 commented on code in PR #29723:
URL: https://github.com/apache/flink/pull/29723#discussion_r4446552054
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/JoinToMultiJoinForReorderRule.java:
##########
@@ -645,23 +646,42 @@ private RexNode shiftRightFilter(
}
/**
- * Combines the post-join filters from the left and right inputs (if they
are MultiJoinRels)
- * into a single AND'd filter.
+ * Combines the post-join filters from the left and right inputs (if they
are MultiJoinRels
+ * combined into the new MultiJoin) into a single AND'd filter. A
MultiJoin that isn't combined,
+ * e.g. the null generating input of an outer join, stays an input of the
new MultiJoin and
+ * keeps its post-join filter, so the filter must not be applied above the
new MultiJoin, too.
*
* @param joinRel the original LogicalJoin
* @param left left child of the LogicalJoin
* @param right right child of the LogicalJoin
* @return combined post-join filters AND'd together
*/
- private List<RexNode> combinePostJoinFilters(Join joinRel, RelNode left,
RelNode right) {
+ private List<RexNode> combinePostJoinFilters(
+ Join joinRel, RelNode left, RelNode right, List<Boolean>
inputNullGenFieldList) {
Review Comment:
Added the missing `@param inputNullGenFieldList`.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/utils/JoinReorderITCaseBase.java:
##########
@@ -377,6 +377,23 @@ public void testBushyTreeJoinReorder(boolean
isBushyJoinReorder)
assertEquals(query, expectedList);
}
+ @ParameterizedTest(name = "Is bushy join reorder: {0}")
+ @ValueSource(booleans = {true, false})
+ public void testJoinReorderWithFilterOnNullGeneratingSideOfLeftOuterJoin(
Review Comment:
Replaced the IT with the semantic test program
`JoinReorderSemanticTestPrograms.FILTER_ON_NULL_GENERATING_SIDE_OF_LEFT_JOIN`,
run in streaming (`JoinReorderSemanticTests`) and batch mode
(`JoinReorderBatchSemanticTests`). Without the fix, both fail: the row of t1
without a match is missing.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/utils/JoinReorderITCaseBase.java:
##########
@@ -377,6 +377,23 @@ public void testBushyTreeJoinReorder(boolean
isBushyJoinReorder)
assertEquals(query, expectedList);
}
+ @ParameterizedTest(name = "Is bushy join reorder: {0}")
+ @ValueSource(booleans = {true, false})
+ public void testJoinReorderWithFilterOnNullGeneratingSideOfLeftOuterJoin(
+ boolean isBushyJoinReorder) {
+ setIsBushyJoinReorder(isBushyJoinReorder);
+ // The filter of tab1 must only be applied below the outer LEFT JOIN,
so the row of T1
+ // without a match in tab1 is kept.
+ String query =
+ "SELECT T1.b1, tab1.b2, tab1.c3 FROM T1 LEFT JOIN "
+ + "(SELECT * FROM T2 LEFT JOIN T3 ON T2.a2 = T3.a3 "
+ + "WHERE COALESCE(T3.b3, T2.b2) > 3) tab1 "
+ + "ON T1.b1 = tab1.b2 WHERE T1.b1 > 5 AND T1.b1 < 9";
+
+ List<String> expectedList = Arrays.asList("6,null,null", "7,7,null",
"8,8,null");
+ assertEquals(query, expectedList);
Review Comment:
Removed together with the IT, see the semantic test.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/utils/JoinReorderITCaseBase.java:
##########
@@ -377,6 +377,23 @@ public void testBushyTreeJoinReorder(boolean
isBushyJoinReorder)
assertEquals(query, expectedList);
}
+ @ParameterizedTest(name = "Is bushy join reorder: {0}")
+ @ValueSource(booleans = {true, false})
+ public void testJoinReorderWithFilterOnNullGeneratingSideOfLeftOuterJoin(
+ boolean isBushyJoinReorder) {
+ setIsBushyJoinReorder(isBushyJoinReorder);
+ // The filter of tab1 must only be applied below the outer LEFT JOIN,
so the row of T1
+ // without a match in tab1 is kept.
+ String query =
+ "SELECT T1.b1, tab1.b2, tab1.c3 FROM T1 LEFT JOIN "
+ + "(SELECT * FROM T2 LEFT JOIN T3 ON T2.a2 = T3.a3 "
+ + "WHERE COALESCE(T3.b3, T2.b2) > 3) tab1 "
+ + "ON T1.b1 = tab1.b2 WHERE T1.b1 > 5 AND T1.b1 < 9";
+
+ List<String> expectedList = Arrays.asList("6,null,null", "7,7,null",
"8,8,null");
Review Comment:
Removed together with the IT, see the semantic test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]