libenchao commented on code in PR #2761:
URL: https://github.com/apache/calcite/pull/2761#discussion_r877011436


##########
core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java:
##########
@@ -225,6 +232,105 @@ protected void perform(RelOptRuleCall call, @Nullable 
Filter filter,
     call.transformTo(relBuilder.build());
   }
 
+  /**
+   * Infer more equal conditions for the Join Condition.
+   *
+   * <p> For example, in {@code SELECT * FROM T1, T2, T3 WHERE T1.id = T3.id 
AND T2.id = T3.id},
+   * we can infer {@code T1.id = T2.id} for the first Join node from second 
Join node's condition:
+   * {@code T1.id = T3.id AND T2.id = T3.id}.
+   *
+   * <p>For the above SQL, the second Join's condition is {@code T1.id = T3.id 
AND T2.id = T3.id}.
+   * After inference, the final condition would be: {@code T1.id = T2.id AND 
T1.id = T3.id}, the
+   * {@code T1.id = T2.id} can be further pushed into LHS.
+   *
+   * @param rexNodes the Join condition
+   * @param join the Join node
+   */
+  protected void inferJoinEqualConditions(List<RexNode> rexNodes, Join join) {
+    final List<Set<Integer>> equalSets = new ArrayList<>();
+    final List<RexNode> result = new ArrayList<>(rexNodes.size());
+    for (RexNode rexNode : rexNodes) {
+      if (rexNode.isA(SqlKind.EQUALS)) {
+        final RexNode op1 = ((RexCall) rexNode).getOperands().get(0);
+        final RexNode op2 = ((RexCall) rexNode).getOperands().get(1);

Review Comment:
   never mind, I've changed it. (In most cases, I also prefer no side-effect 
methods, they are more readable and maintainable)



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