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


##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -362,22 +359,16 @@ public static boolean isDeterministic(RelNode rel) {
     return false;
   }
 
-  /** Visits a supported node's expression fields for read-only analysis.
+  /** Applies a shuttle to one relational node's expression fields.
+   * Relational inputs are not visited.
    *
-   * <p>Does not visit relational inputs, expand planner wrappers, visit
-   * literal-only data (such as {@link Values} tuples and {@link Window}
-   * constants), or apply rewritten expressions. The visitor controls traversal
-   * inside expressions, including sub-query plans. The same expression may be
-   * visited more than once.
-   *
-   * <p>An unsupported operator family returns false without invoking the
-   * visitor. A supported operator may have no expressions to visit. Exceptions
-   * thrown by the visitor are propagated.
+   * <p>The shuttle controls visits to expression children and sub-query plans.
+   * Rewritten expressions are ignored. An expression may be visited more than 
once.
    *
    * @param rel Relational expression whose fields to visit
    * @param visitor Visitor used for read-only analysis
-   * @return Whether the operator family is supported; true after visiting its
-   *     expression fields, false without invoking the visitor
+   * @return True if this method can visit expressions for the node type, even

Review Comment:
   "for the node type" -- what node type?
   Maybe "kind"? 
   Moreover, there is no "node", only a "rel".
   "type" means many things.
   



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -208,12 +216,20 @@ private static RelNode visitCorrelationScope(RelNode 
root, CorrelationId id,
     });
   }
 
-  /** Selects outermost deterministic computations over one correlation.
+  /** Selects deterministic expressions for evaluation on the outer input.
+   *
+   * <p>The collector stores each selected {@link RexNode} with its offset 
among

Review Comment:
   what is the collector?



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -208,12 +216,20 @@ private static RelNode visitCorrelationScope(RelNode 
root, CorrelationId id,
     });
   }
 
-  /** Selects outermost deterministic computations over one correlation.
+  /** Selects deterministic expressions for evaluation on the outer input.
+   *
+   * <p>The collector stores each selected {@link RexNode} with its offset 
among
+   * the fields added to the left input. A Project computes these fields.
+   * The replacement visitor replaces their uses on the right with

Review Comment:
   what is the replacement visitor?



##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -362,22 +359,16 @@ public static boolean isDeterministic(RelNode rel) {
     return false;
   }
 
-  /** Visits a supported node's expression fields for read-only analysis.
+  /** Applies a shuttle to one relational node's expression fields.
+   * Relational inputs are not visited.
    *
-   * <p>Does not visit relational inputs, expand planner wrappers, visit
-   * literal-only data (such as {@link Values} tuples and {@link Window}
-   * constants), or apply rewritten expressions. The visitor controls traversal
-   * inside expressions, including sub-query plans. The same expression may be
-   * visited more than once.
-   *
-   * <p>An unsupported operator family returns false without invoking the
-   * visitor. A supported operator may have no expressions to visit. Exceptions
-   * thrown by the visitor are propagated.
+   * <p>The shuttle controls visits to expression children and sub-query plans.
+   * Rewritten expressions are ignored. An expression may be visited more than 
once.

Review Comment:
   What does it mean "rewritten expressions are ignored"?
   Who ignores them?



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelationReferences.java:
##########
@@ -36,11 +36,14 @@
 
 import java.util.Set;
 
-/** Conservatively analyzes references to correlation bindings outside a
- * relational tree without changing it.
+/** Checks for references to correlation bindings outside a relational tree.
  *
- * <p>Local bindings hide references only within their scope. Regions with
- * unknown expression coverage or binding scopes may contain outer references. 
*/
+ * <p>Records whether outer bindings may be referenced and which declared
+ * fields may still be needed.
+ *
+ * <p>A local binding hides the outer binding with the same id in its scope.

Review Comment:
   see my comment above. But perhaps this is unavoidable if this is the normal 
behavior of many passes.



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -187,7 +191,11 @@ private static boolean isDirectFieldAccess(RexNode node, 
CorrelationId id) {
     return builder.build();
   }
 
-  /** Applies the visitor within the specified correlation scope. */
+  /** Applies the visitor within the scope of an outer correlation binding.
+   *
+   * <p>The scope is the part of {@code root} where {@code id} refers to the
+   * binding defined outside {@code root}. References to nested bindings

Review Comment:
   I never understood this business about nested bindings with the same id. I 
think these should be illegal plans. The plans are complicated enough as it is. 
We should use alpha-renaming if there is a confusion about reused names.



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -208,12 +216,20 @@ private static RelNode visitCorrelationScope(RelNode 
root, CorrelationId id,
     });
   }
 
-  /** Selects outermost deterministic computations over one correlation.
+  /** Selects deterministic expressions for evaluation on the outer input.
+   *
+   * <p>The collector stores each selected {@link RexNode} with its offset 
among
+   * the fields added to the left input. A Project computes these fields.
+   * The replacement visitor replaces their uses on the right with
+   * {@link RexFieldAccess} references.
+   *
+   * <p>Selected expressions go to {@link #selected(RexNode)} without visiting

Review Comment:
   This should probably be part of the JavaDoc of "selected".



##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -208,12 +216,20 @@ private static RelNode visitCorrelationScope(RelNode 
root, CorrelationId id,
     });
   }
 
-  /** Selects outermost deterministic computations over one correlation.
+  /** Selects deterministic expressions for evaluation on the outer input.
+   *
+   * <p>The collector stores each selected {@link RexNode} with its offset 
among
+   * the fields added to the left input. A Project computes these fields.
+   * The replacement visitor replaces their uses on the right with
+   * {@link RexFieldAccess} references.
+   *
+   * <p>Selected expressions go to {@link #selected(RexNode)} without visiting
+   * their operands. Other calls have their operands checked separately.
+   * Lambda bodies and sub-query plans are skipped. A complete call containing

Review Comment:
   what is a "complete call"?



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