dssysolyatin commented on code in PR #4691:
URL: https://github.com/apache/calcite/pull/4691#discussion_r2635790703
##########
core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java:
##########
@@ -673,7 +673,7 @@ public TrimResult trimFields(
// Build new filter with trimmed input and condition.
relBuilder.push(newInput)
- .filter(filter.getVariablesSet(), newConditionExpr);
+ .filter(correlationIds, newConditionExpr);
Review Comment:
> However, if a subquery in the join condition uses a correlated variable
(call it cor0) from the current scope, that cor0 is intended to represent the
concatenation of the left and right rows, not only variable originating from
the left input. That interpretation does not match the variablesSet concept in
LogicalJoin, so the CorrelationId used by the subquery is not added to
variablesSet. This explains why LogicalJoin.variablesSet is always empty even
though the join condition contains correlated variables from the current scope.
In other words, we are forced to treat free variables used by subqueries in
join condition as coming from the current scope rather than from outer scopes,
which also causes problems with removing nested correlated subqueries and
decorrelating them.
Interesting, if we can transform such cases to ?
```
LogicalCorrelate(correlation=[$cor0])
LogicalJoin(condition=TRUE)
LogicalFilter(condition=on_condition)
```
Or is it illegal ?
--
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]