xiedeyantu commented on code in PR #4788:
URL: https://github.com/apache/calcite/pull/4788#discussion_r2778453381
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -3882,7 +3882,26 @@ private void createAggImpl(Blackboard bb,
// implement the SELECT list
relBuilder.project(projects.leftList(), projects.rightList())
.rename(projects.rightList());
- bb.setRoot(relBuilder.build(), false);
+
+ RelNode tmpProject = relBuilder.build();
+
+ // Check for correlation variables that may be used in the SELECT list
+ final RelNode finalProject;
+ final CorrelationUse correlationUse = getCorrelationUse(bb, tmpProject);
+ if (correlationUse != null) {
+ assert correlationUse.r instanceof Project;
+ // correlation variables have been normalized in correlationUse.r,
+ // we should use expressions in correlationUse.r
+ Project project1 = (Project) correlationUse.r;
+ finalProject = relBuilder.push(bb.root())
Review Comment:
Yes, there should be an omission here. However, it's strange that there were
no error cases reported despite this omission. Do you understand what this line
is doing? I might need to spend more time confirming it here.
--
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]