silundong commented on code in PR #4788:
URL: https://github.com/apache/calcite/pull/4788#discussion_r2778414607
##########
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:
Would using `bb.root()` here cause the `Filter` on L3880 to be lost?
> relBuilder.filter(variableSet, havingExpr);
--
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]