suibianwanwank commented on code in PR #4437:
URL: https://github.com/apache/calcite/pull/4437#discussion_r2166071668


##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -4552,34 +4580,45 @@ private void acceptFields(final List<RelDataTypeField> 
fields) {
     }
   }
 
-  /** Extension of {@link RelOptUtil.InputFinder} with optional subquery 
lookup. */
-  public static class SubQueryAwareInputFinder extends RelOptUtil.InputFinder {
-    boolean visitSubQuery;
-
-    public SubQueryAwareInputFinder(@Nullable Set<RelDataTypeField> 
extraFields,
-        boolean visitSubQuery) {
-      super(extraFields, ImmutableBitSet.builder());
-      this.visitSubQuery = visitSubQuery;
-    }
+  /**
+   * Updates correlate references in {@link RexNode} expressions.
+   */
+  public static class RexCorrelVariableMapShuttle extends RexShuttle {
+    private final CorrelationId correlationId;
+    private final Mapping mapping;
+    private final RelDataType newCorrelRowType;
+    private final RexBuilder rexBuilder;
 
-    @Override public Void visitSubQuery(RexSubQuery subQuery) {
-      if (visitSubQuery && subQuery.getKind() == SqlKind.SCALAR_QUERY) {
-        subQuery.rel.accept(new RelHomogeneousShuttle() {
-          @Override public RelNode visit(LogicalProject project) {
-            project.getProjects().forEach(r -> 
r.accept(SubQueryAwareInputFinder.this));
-            return super.visit(project);
-          }
 
-          @Override public RelNode visit(LogicalFilter filter) {
-            filter.getCondition().accept(SubQueryAwareInputFinder.this);
-            return super.visit(filter);
-          }
-        });
+    /**
+     * Constructs a RexCorrelVariableMapShuttle.
+     *
+     * @param correlationId The ID of the correlation variable to update.
+     * @param newCorrelRowType The new row type for the correlate reference.
+     * @param mapping Mapping to transform field indices.
+     * @param rexBuilder A builder for constructing new RexNodes.
+     */
+    public RexCorrelVariableMapShuttle(final CorrelationId correlationId,
+        RelDataType newCorrelRowType, Mapping mapping, RexBuilder rexBuilder) {
+      this.correlationId = correlationId;
+      this.newCorrelRowType = newCorrelRowType;
+      this.mapping = mapping;
+      this.rexBuilder = rexBuilder;
+    }
 
-        return null;
-      } else {
-        return super.visitSubQuery(subQuery);
+    @Override public RexNode visitFieldAccess(final RexFieldAccess 
fieldAccess) {

Review Comment:
   LGTM. I’ll merge it within 24 hours if no further comments come in.



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