You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "zabetak (via GitHub)" <gi...@apache.org> on 2023/04/21 15:09:30 UTC

[GitHub] [calcite] zabetak opened a new pull request, #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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

   …


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


[GitHub] [calcite] zabetak commented on a diff in pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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


##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -3646,6 +3649,104 @@ private void checkRightEmptyAntiJoin(JoinRelType type) {
     checkEmptyJoin(relFn(relFn));
   }
 
+  @Test void testCorrelateWithoutCorrelationToEmpty() {
+    String sql = "select * from emp e where exists (select 1 from dept where empno=null)";
+    List<RelOptRule> rules =
+        Arrays.asList(CoreRules.FILTER_REDUCE_EXPRESSIONS,
+        PruneEmptyRules.PROJECT_INSTANCE,
+        PruneEmptyRules.AGGREGATE_INSTANCE,
+        PruneEmptyRules.JOIN_RIGHT_INSTANCE,
+        CoreRules.CORRELATE_TO_JOIN_RULE);
+    sql(sql)
+        .withExpand(false)
+        .withPreRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+        .withProgram(HepProgram.builder().addRuleCollection(rules).build())
+        .check();
+  }
+
+  @Test void testInnerCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.INNER, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testSemiCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.SEMI, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testAntiCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.ANTI, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testLeftCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.LEFT, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testInnerCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.INNER, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testLeftCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.LEFT, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testSemiCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.SEMI, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testAntiCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.ANTI, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  /**
+   * Provides a function that will create a simple plan correlating EMP and DEPT tables with the
+   * provided join type.

Review Comment:
   Method doesn't exist in latest patch.



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


[GitHub] [calcite] sonarcloud[bot] commented on pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3170)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL)
   
   [![94.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png '94.3%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list) [94.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list)
   
   


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


[GitHub] [calcite] sonarcloud[bot] commented on pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3170)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL)
   
   [![95.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png '95.9%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list) [95.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list)
   
   


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


[GitHub] [calcite] sonarcloud[bot] commented on pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3170)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL)
   
   [![95.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png '95.9%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list) [95.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list)
   
   


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


[GitHub] [calcite] zabetak closed pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak closed pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused
URL: https://github.com/apache/calcite/pull/3170


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


[GitHub] [calcite] zabetak commented on a diff in pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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


##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -4674,6 +4675,9 @@ private static class CorrelationCollector extends RelHomogeneousShuttle {
     private final VariableUsedVisitor vuv = new VariableUsedVisitor(this);
 
     @Override public RelNode visit(RelNode other) {
+      if (other instanceof HepRelVertex) {

Review Comment:
   The `RelOptUtil` class remains unchanged in the latest patch so no need to cherry-pick anything.



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


[GitHub] [calcite] sonarcloud[bot] commented on pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3170)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3170&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3170&resolved=false&types=CODE_SMELL)
   
   [![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png '100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3170&metric=new_duplicated_lines_density&view=list)
   
   


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


[GitHub] [calcite] julianhyde commented on a diff in pull request #3170: [CALCITE-5669] Add rule to transform correlate to join when correlation variable is unused

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


##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -4674,6 +4675,9 @@ private static class CorrelationCollector extends RelHomogeneousShuttle {
     private final VariableUsedVisitor vuv = new VariableUsedVisitor(this);
 
     @Override public RelNode visit(RelNode other) {
+      if (other instanceof HepRelVertex) {

Review Comment:
   You might like to cherry-pick in my 5fb70e196ddafaceaf1349378de88e48f9f232f3 commit, which adds the `RelNode.stripped()`. With that commit, this `if` might not be required.



##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -3646,6 +3649,104 @@ private void checkRightEmptyAntiJoin(JoinRelType type) {
     checkEmptyJoin(relFn(relFn));
   }
 
+  @Test void testCorrelateWithoutCorrelationToEmpty() {
+    String sql = "select * from emp e where exists (select 1 from dept where empno=null)";
+    List<RelOptRule> rules =
+        Arrays.asList(CoreRules.FILTER_REDUCE_EXPRESSIONS,
+        PruneEmptyRules.PROJECT_INSTANCE,
+        PruneEmptyRules.AGGREGATE_INSTANCE,
+        PruneEmptyRules.JOIN_RIGHT_INSTANCE,
+        CoreRules.CORRELATE_TO_JOIN_RULE);
+    sql(sql)
+        .withExpand(false)
+        .withPreRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+        .withProgram(HepProgram.builder().addRuleCollection(rules).build())
+        .check();
+  }
+
+  @Test void testInnerCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.INNER, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testSemiCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.SEMI, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testAntiCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.ANTI, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testLeftCorrelateWithoutCorrelationToJoin() {
+    relFn(correlationPlanBuilder(JoinRelType.LEFT, false))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .check();
+  }
+
+  @Test void testInnerCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.INNER, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testLeftCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.LEFT, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testSemiCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.SEMI, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  @Test void testAntiCorrelateWithCorrelationUnchanged() {
+    relFn(correlationPlanBuilder(JoinRelType.ANTI, true))
+        .withRule(CoreRules.CORRELATE_TO_JOIN_RULE)
+        .checkUnchanged();
+  }
+
+  /**
+   * Provides a function that will create a simple plan correlating EMP and DEPT tables with the
+   * provided join type.

Review Comment:
   please add `<p>` at start of paragraphs



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