mihaibudiu commented on code in PR #4580:
URL: https://github.com/apache/calcite/pull/4580#discussion_r2440581649
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -3129,6 +3130,8 @@ protected RelNode createAsofJoin(
}
final ImmutableBitSet.Builder requiredColumns = ImmutableBitSet.builder();
final List<CorrelationId> correlNames = new ArrayList<>();
+ // Mapping from (correlId, originalFieldIndex) to projectedFieldIndex for
aggregation
+ final Map<Pair<CorrelationId, Integer>, Integer> fieldMapping = new
HashMap<>();
Review Comment:
why not `Map<CorrelationId, Map<Integer, Integer>>`?
Maybe it doesn't really matter.
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -6006,6 +6021,46 @@ RexFieldAccess getFieldAccess(CorrelationId name) {
}
}
+ /**
+ * Shuttle that rewrites correlation field accesses to use projected field
indices
+ * when correlation references aggregated relations.
+ */
+ private static class CorrelationFieldMappingShuttle extends
RelHomogeneousShuttle {
+ private final RexBuilder rexBuilder;
+ private final CorrelationId targetCorrelId;
+ private final RelDataType newCorrelRowType;
+ private final Map<Pair<CorrelationId, Integer>, Integer> fieldMapping;
+
+ CorrelationFieldMappingShuttle(RexBuilder rexBuilder,
+ CorrelationId targetCorrelId,
+ RelDataType newCorrelRowType,
+ Map<Pair<CorrelationId, Integer>, Integer> fieldMapping) {
+ this.rexBuilder = rexBuilder;
+ this.targetCorrelId = targetCorrelId;
+ this.newCorrelRowType = newCorrelRowType;
+ this.fieldMapping = fieldMapping;
+ }
+
+ @Override public RelNode visit(RelNode other) {
Review Comment:
does this visit subqueries too?
or are there no subqueries left at this point?
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -3129,6 +3130,8 @@ protected RelNode createAsofJoin(
}
final ImmutableBitSet.Builder requiredColumns = ImmutableBitSet.builder();
final List<CorrelationId> correlNames = new ArrayList<>();
+ // Mapping from (correlId, originalFieldIndex) to projectedFieldIndex for
aggregation
Review Comment:
what aggregation?
Maybe a comment would help.
--
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]