NobiGo commented on code in PR #4226:
URL: https://github.com/apache/calcite/pull/4226#discussion_r1981016575
##########
core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java:
##########
@@ -213,7 +213,8 @@ protected FilterProjectTransposeRule(
public interface Config extends RelRule.Config {
Config DEFAULT = ImmutableFilterProjectTransposeRule.Config.of()
.withOperandFor(Filter.class,
- f -> !RexUtil.containsCorrelation(f.getCondition()),
+ f -> !RexUtil.containsCorrelation(f.getCondition())
+ && !RexUtil.SubQueryFinder.containsSubQuery(f),
Review Comment:
The new condition mainly prevents filter push-down for correlated
sub-queries.
The RexUtil.containsCorrelation cannot detect all the correlations in the
Subquery.
Because in RexVisitorImpl (CorrelationFinder):
```
@Override public R visitSubQuery(RexSubQuery subQuery) {
if (!deep) {
return null;
}
R r = null;
for (RexNode operand : subQuery.operands) {
r = operand.accept(this);
}
return r;
}
```
Correlation not only exists in operands but also may exist in Rel.
For example:
EXISTS subquery operands are empty, and the query in Rel.
--
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]