SteveStevenpoor commented on code in PR #27166:
URL: https://github.com/apache/flink/pull/27166#discussion_r2493643438


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/MultiJoinTest.java:
##########
@@ -684,4 +691,631 @@ void testMultiSinkOnMultiJoinedView() {
                 false,
                 false);
     }
+
+    /*
+     * Calcite adds a LogicalProject to compute expressions such as UPPER and 
FLOOR
+     * on the necessary fields. As a result, the planner cannot fuse all joins 
into
+     * a single MultiJoin node initially.
+     */
+    @Test
+    void testFourWayJoinNoCommonJoinKeyWithFunctionInCondition() {
+        util.verifyRelPlan(
+                "SELECT u.user_id, u.name, o.order_id, p.payment_id, 
s.location "
+                        + "FROM Users u "
+                        + "LEFT JOIN Orders o ON o.user_id = u.user_id "
+                        + "LEFT JOIN Payments p ON u.user_id = p.user_id "
+                        + "     AND UPPER(u.name) = UPPER(p.payment_id) "
+                        + "     AND (FLOOR(u.cash) >= FLOOR(p.price) OR 
p.price < 0) "
+                        + "LEFT JOIN Shipments s ON p.payment_id = s.location 
");
+    }
+
+    /*
+     * We expect the join inputs to **not** merge into a single MultiJoin node 
in this case,
+     * because `documents.common_id` is different from 
`other_documents.common_id`.
+     */
+    @Test
+    void testComplexCommonJoinKeyMissingProjection() {
+        util.tableEnv()
+                .executeSql(
+                        "CREATE TABLE Assignments ("
+                                + "  assignment_id STRING PRIMARY KEY NOT 
ENFORCED,"
+                                + "  user_id STRING,"
+                                + "  detail_id STRING,"
+                                + "  common_id STRING"
+                                + ") WITH ('connector' = 'values', 
'changelog-mode' = 'I,UA,D')");
+
+        util.tableEnv()
+                .executeSql(
+                        "CREATE TABLE Documents ("
+                                + "  detail_id STRING PRIMARY KEY NOT 
ENFORCED,"
+                                + "  creator_nm STRING,"
+                                + "  common_id STRING"
+                                + ") WITH ('connector' = 'values', 
'changelog-mode' = 'I,UA,D')");
+
+        util.verifyRelPlan(

Review Comment:
   It works, but since `other_documents` doesn’t have a 
`commonConceptualAttributeSet` (please correct me if I’m wrong), it won’t be 
combined into a single `MultiJoin` node. There’s no exception in this version. 
I've tested it and everything seems to work as expected.
   



-- 
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]

Reply via email to