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


##########
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -865,6 +866,9 @@ private static void matchFilter(SubQueryRemoveRule rule,
           LogicVisitor.find(RelOptUtil.Logic.TRUE, ImmutableList.of(c), e);
       final Set<CorrelationId>  variablesSet =
           RelOptUtil.getVariablesUsed(e.rel);
+      if (!filterVariablesSet.isEmpty()) {
+        variablesSet.retainAll(filterVariablesSet);

Review Comment:
   The change looks good to me, and this was also introduced in 
https://github.com/apache/calcite/pull/3193, (it seems that the author reverts 
this change in the latest version).   
   
   But I found after this change, there is one test that produces incorrect 
result, see my latest 
comment(https://github.com/apache/calcite/pull/3193#issuecomment-1596028987). 
I'm not sure whether it's a regression, if not, I think we can safely merge 
this one.



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