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


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -547,9 +552,97 @@ public Result visit(Correlate e) {
     return result(join, leftResult, rightResult);
   }
 
+  /**
+   * Returns whether any expression (including nested sub-queries) references 
a correlated variable
+   * defined by the given input and having the same row type.
+   */
+  private static boolean inputRowTypeMatchesCorrelVariable(
+      RelNode input,
+      Set<CorrelationId> correlIds,
+      Iterable<? extends RexNode> exprs) {
+
+    if (correlIds.isEmpty()) {
+      return false;
+    }
+
+    final RelDataType inputRowType = input.getRowType();
+
+    /** Visitor that detects matching correlated variables. */
+    class Finder extends RexVisitorImpl<Void> {
+      boolean found;
+
+      Finder() {
+        super(true);
+      }
+
+      @Override public Void visitCorrelVariable(RexCorrelVariable v) {
+        if (correlIds.contains(v.id)

Review Comment:
   The JavaDoc above says: "a correlated variable defined by the given input"
   Where is this check validating this fact?
   (I am not sure how "defined by an input" is defined)



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