Dwrite commented on code in PR #5036:
URL: https://github.com/apache/calcite/pull/5036#discussion_r3482189926
##########
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:
Sorry, that's my english fault, The wording is inaccurate. The method does
not actually verify that the correlation variable is defined by the given
input; it only checks for a correlated reference with a matching row type. I'll
update the Javadoc to reflect what it actually does.
--
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]