zabetak commented on code in PR #5231:
URL: https://github.com/apache/calcite/pull/5231#discussion_r3901758332


##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -115,8 +116,11 @@ private static boolean isDirectFieldAccess(RexNode node, 
CorrelationId id) {
     boolean isTrivialCorrelation =
         callsWithCorrelationInRight.stream()
             .allMatch(exp -> isDirectFieldAccess(exp, 
correlate.getCorrelationId()));
+    // A nested correlate on the right re-binding the same id owns the refs 
below it.
+    boolean rightRebindsCorrelationId =
+        rebindsCorrelationId(right, correlate.getCorrelationId());

Review Comment:
   I am wondering if its possible to plug the fix in 
`findCorrelationDependentCalls` to avoid traversing again a potentially large 
sub plan? How about stopping traversal inside findCorrelationDependentCalls if 
we encounter a correlate with the same id?



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