zzwqqq commented on code in PR #5385:
URL: https://github.com/apache/calcite/pull/5385#discussion_r4534687454


##########
core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java:
##########
@@ -1035,7 +1071,14 @@ private static void shiftMapping(Map<Integer, Integer> 
mapping, int startIndex,
    */
   public @Nullable Frame getInvoke(RelNode r, boolean isCorVarDefined,
       @Nullable RelNode parent, boolean parentPropagatesNullValues) {
-    final Frame frame = dispatcher.invoke(r, isCorVarDefined, 
parentPropagatesNullValues);
+    final Frame frame;
+    if (!(r instanceof Correlate) && !r.getVariablesSet().isEmpty()) {
+      // Local bindings need their own field remapping. Only the Correlate

Review Comment:
   The guard skips nodes that define correlation variables, except `Correlate`. 
Decorrelation can change the positions of their input fields. References 
through those variables are not remapped, so they could still use the old 
positions. Returning `null` prevents this rewrite. I've made the comment 
clearer.



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