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


##########
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -866,6 +866,12 @@ private static void matchFilter(SubQueryRemoveRule rule,
           LogicVisitor.find(RelOptUtil.Logic.TRUE, ImmutableList.of(c), e);
       final Set<CorrelationId>  variablesSet =
           RelOptUtil.getVariablesUsed(e.rel);
+      // Only consider the correlated variables which originated from this 
sub-query level.
+      if (!filter.getVariablesSet().isEmpty()) {
+        // Only retain when filter has non-empty correlated variables set to 
avoid removing
+        // all the correlated variables from parent scope.

Review Comment:
   This comment explains why the `if (...)` exists, how about moving it above 
the `if (...)`. (switch with the current `if (...)` comment)



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