mihaibudiu commented on code in PR #5031:
URL: https://github.com/apache/calcite/pull/5031#discussion_r4485280253


##########
core/src/main/java/org/apache/calcite/sql2rel/TopDownGeneralDecorrelator.java:
##########
@@ -232,14 +233,32 @@ public static RelNode decorrelateQuery(RelNode rel, 
RelBuilder builder) {
     prePlanner.setRoot(rel);
     RelNode preparedRel = prePlanner.findBestExp();
 
+    // Extract computations over correlated variables from the right side of
+    // a Correlate into its left input, like RelDecorrelator does. Rewrites
+    // that require the right side to access correlated fields directly (such
+    // as CorrelateUncollectMergeRule) can then apply.
+    preparedRel = preparedRel.accept(new 
CorrelateProjectExtractor(RelFactories.LOGICAL_BUILDER));

Review Comment:
   I think there's a separate PR dealing with decorrelation of nondeterministic 
expressions: #5385.
   If that doesn't address it, we may need to revisit.



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