korlov42 commented on a change in pull request #2623:
URL: https://github.com/apache/calcite/pull/2623#discussion_r761937587



##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -4346,7 +4336,21 @@ private void convertSelectList(
 
     relBuilder.push(bb.root())
         .projectNamed(exprs, fieldNames, true);
-    bb.setRoot(relBuilder.build(), false);
+
+    RelNode project = relBuilder.build();
+
+    final RelNode r;
+    final CorrelationUse p = getCorrelationUse(bb, project);
+    if (p != null) {
+      assert p.r instanceof Project;
+      Project proj = (Project) p.r;
+      r = LogicalProject.create(proj.getInput(), proj.getHints(),

Review comment:
       I think this assertion primary used to avoid "Unchecked cast" warning 
throwing by a static code analyzers. Here we are converting sqlNode to a 
relation tree, so LogicalProject is a reasonable result. Parent class `Project` 
give us sufficent information to create a new `LogicalProject` with found set 
of correlated variables.
   
   We could use the `relBuilder`, but it doesn't change a lot.




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