You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xiedeyantu (via GitHub)" <gi...@apache.org> on 2026/02/07 04:10:49 UTC

[PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

xiedeyantu opened a new pull request, #4788:
URL: https://github.com/apache/calcite/pull/4788

   See [CALCITE-7411](https://issues.apache.org/jira/browse/CALCITE-7411)


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4788:
URL: https://github.com/apache/calcite/pull/4788#issuecomment-3867213740

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [92.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4788:
URL: https://github.com/apache/calcite/pull/4788#issuecomment-3869051107

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [92.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4788:
URL: https://github.com/apache/calcite/pull/4788#issuecomment-3867358555

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [92.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "silundong (via GitHub)" <gi...@apache.org>.
silundong merged PR #4788:
URL: https://github.com/apache/calcite/pull/4788


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4788:
URL: https://github.com/apache/calcite/pull/4788#discussion_r2779260680


##########
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:
   I have fixed this issue. I checked and the `filter` was introduced in [CALCITE-5683](https://issues.apache.org/jira/browse/CALCITE-5683), and it was used to handle scenarios where there are nested subqueries in the WHERE clause.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "silundong (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-7411] When a SCALAR_QUERY in PROJECT contains correlated variables execution fails using TopDownGeneralDecorrelator [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4788:
URL: https://github.com/apache/calcite/pull/4788#issuecomment-3865503807

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4788&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4788&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [92.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4788&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4788)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org