godfreyhe commented on code in PR #21489:
URL: https://github.com/apache/flink/pull/21489#discussion_r1057475102


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DynamicPartitionPruningUtils.java:
##########
@@ -201,33 +224,128 @@ private static void visitFactSide(
                             .collect(Collectors.toList());
             ImmutableIntList inputJoinKeys = getInputIndices(projects, 
joinKeys);
             if (inputJoinKeys.isEmpty()) {
-                factSideFactors.isSuitableJoinKey = false;
-                return;
+                return rel;
             }
 
-            visitFactSide(rel.getInput(0), factSideFactors, inputJoinKeys);
+            return rel.copy(
+                    rel.getTraitSet(),
+                    Collections.singletonList(
+                            convertDppFactSide(
+                                    rel.getInput(0),
+                                    inputJoinKeys,
+                                    dimSide,
+                                    dimSideJoinKey,
+                                    factSideFactors,
+                                    join)));
+        } else if (rel instanceof Join) {
+            Join currentJoin = (Join) rel;
+            return currentJoin.copy(
+                    currentJoin.getTraitSet(),
+                    Arrays.asList(
+                            convertDppFactSide(
+                                    currentJoin.getLeft(),
+                                    getInputIndices(currentJoin, joinKeys, 
true),
+                                    dimSide,
+                                    dimSideJoinKey,
+                                    factSideFactors,
+                                    join),
+                            convertDppFactSide(
+                                    currentJoin.getRight(),
+                                    getInputIndices(currentJoin, joinKeys, 
false),
+                                    dimSide,
+                                    dimSideJoinKey,
+                                    factSideFactors,
+                                    join)));
+        } else if (rel instanceof Union) {
+            Union union = (Union) rel;
+            List<RelNode> newInputs = new ArrayList<>();
+            for (RelNode input : union.getInputs()) {
+                newInputs.add(
+                        convertDppFactSide(
+                                input, joinKeys, dimSide, dimSideJoinKey, 
factSideFactors, join));
+            }
+            return union.copy(union.getTraitSet(), newInputs, union.all);
+        } else if (rel instanceof BatchPhysicalGroupAggregateBase) {
+            BatchPhysicalGroupAggregateBase agg = 
(BatchPhysicalGroupAggregateBase) rel;
+            List<RelNode> newInputs = new ArrayList<>();
+            for (RelNode input : agg.getInputs()) {
+                newInputs.add(
+                        convertDppFactSide(
+                                input,
+                                getInputIndices(agg, input, joinKeys),
+                                dimSide,
+                                dimSideJoinKey,
+                                factSideFactors,
+                                join));
+            }
+
+            return agg.copy(agg.getTraitSet(), newInputs);
         }

Review Comment:
   the `else` branch is the relnodes which are unsupported now, It's better we 
can defined the supported pattern to avoid unexpected behavior



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