yashlimbad commented on code in PR #4840:
URL: https://github.com/apache/calcite/pull/4840#discussion_r2958566412


##########
core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java:
##########
@@ -198,14 +200,39 @@ protected void perform(RelOptRuleCall call, @Nullable 
Filter filter,
       return;
     }
 
+    Set<CorrelationId> variablesSet;
+    Set<CorrelationId> leftVariablesSet =  new LinkedHashSet<>();
+    Set<CorrelationId> rightVariablesSet = new LinkedHashSet<>();
+    if (filter == null) {
+      variablesSet = ImmutableSet.of();
+    } else {
+      variablesSet = new LinkedHashSet<>(filter.getVariablesSet());
+      for (RexNode condition : leftFilters) {
+        RexSubQuery rexSubQuery = RexUtil.SubQueryFinder.find(condition);
+        if (rexSubQuery != null) {
+          
leftVariablesSet.addAll(RelOptUtil.getVariablesUsed(rexSubQuery.rel));
+        }
+      }
+
+      for (RexNode condition : rightFilters) {
+        RexSubQuery rexSubQuery = RexUtil.SubQueryFinder.find(condition);
+        if (rexSubQuery != null) {
+          
rightVariablesSet.addAll(RelOptUtil.getVariablesUsed(rexSubQuery.rel));
+        }
+      }
+
+      variablesSet.addAll(leftVariablesSet);
+      variablesSet.addAll(rightVariablesSet);
+    }
+

Review Comment:
   nice catch! updating code



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