libenchao commented on code in PR #3193:
URL: https://github.com/apache/calcite/pull/3193#discussion_r1204993079
##########
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -866,6 +866,8 @@ 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*/
+ variablesSet.retainAll(filter.getVariablesSet());
Review Comment:
This seems correct only when we have already set the variable for `Filter`
(which I believe is the right direction), however I'm not sure we can guarantee
that for now. That says, we can still handle the cases that the `Filter` is not
set the variable, and maybe this would be an regression in some sense (or we
can name it a breaking change if we deliberately want to break it) . For
downstream projects, there may exist such usages, even we can pass all the
tests of Calcite.
--
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]