swuferhong commented on code in PR #21489:
URL: https://github.com/apache/flink/pull/21489#discussion_r1057118501
##########
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:
> we should throw exception for the `else` branch ?
I think it cannot throw exception for `else` branch. The goal of this method
is to find out whether current join side can be convert to fact side, and if it
can do that, we will return a new
`BatchPhysicalDynamicFilteringTableSourceScan`, if not, we will return the
origin tree. so it need not to throw exception even if we don't consider all
node optinons in our judgement branch. WDYT ?
--
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]