davidradl commented on code in PR #27166:
URL: https://github.com/apache/flink/pull/27166#discussion_r2472603762
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/JoinToMultiJoinRule.java:
##########
@@ -234,11 +236,53 @@ public void onMatch(RelOptRuleCall call) {
Pair.left(joinSpecs),
projFieldsList,
com.google.common.collect.ImmutableMap.copyOf(newJoinFieldRefCountsMap),
- RexUtil.composeConjunction(rexBuilder,
newPostJoinFilters, true));
+ RexUtil.composeConjunction(rexBuilder,
newPostJoinFilters, true),
+ newCommonJoinKeys);
call.transformTo(multiJoin);
}
+ /**
+ * Creates a Map {join condition -> field names} which has all the
conditions containing common
+ * join key and all the keys equal to it.
+ *
+ * @param origJoin original Join node
+ * @param left left child of the Join node
+ * @return Map {join condition -> field names}
+ */
+ private Map<RexCall, Set<String>> combineJoinKeys(Join origJoin, RelNode
left) {
+ Map<RexCall, Set<String>> newCondToFieldsMap =
getCondToFieldsMap(origJoin);
+
+ if (canCombine(left, origJoin)) {
+ final MultiJoin multiJoin = (MultiJoin) left;
+ Map<RexCall, Set<String>> origCondToKeys =
getCondToFieldsMap(origJoin);
+ Map<RexCall, Set<String>> multiJoinCondToKeys =
multiJoin.getConditionsToFieldsMap();
+
+ for (Map.Entry<RexCall, Set<String>> origEntry :
origCondToKeys.entrySet()) {
+ boolean intersects = false;
+ Set<String> origKeys = origEntry.getValue();
Review Comment:
@gustavodemorais I am thinking this might be more confusing. origJoin -
meaning original join seems good to me. It looks like we are going thought the
origJoin keys and looking for a match in the left. The newCondToFieldsMap keys
would be a subset of the origKeys.
If we want to rename for readability, I suggest :
newCondToFieldsMap -> condToCommonFieldsMap
combineJoinKeys -> getCommonJoinKeysForCondition
--
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]