You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/12/14 19:57:29 UTC

[GitHub] [calcite] rubenada commented on a change in pull request #2647: [CALCITE-4941] SemiJoinRule loses hints

rubenada commented on a change in pull request #2647:
URL: https://github.com/apache/calcite/pull/2647#discussion_r768998784



##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -1077,6 +1081,48 @@ private void checkSemiOrAntiJoinProjectTranspose(JoinRelType type) {
         .check();
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-4941">[CALCITE-4941]
+   * SemiJoinRule loses hints</a>. */
+  @Test void testSemiJoinRuleWithHint() {
+    final RelHint noHashJoinHint = RelHint.builder("no_hash_join").build();
+    final Function<RelBuilder, RelNode> relFn = b -> {
+      b.getCluster().setHintStrategies(
+          HintStrategyTable.builder()
+              .hintStrategy("no_hash_join", HintPredicates.JOIN)
+              .build());
+      return b
+          .scan("DEPT")
+          .scan("EMP")
+          .project(b.field("DEPTNO"))
+          .distinct()
+          .join(
+              JoinRelType.INNER,
+              b.equals(
+                  b.field(2, 0, "DEPTNO"),
+                  b.field(2, 1, "DEPTNO"))).hints(noHashJoinHint)
+          .project(b.field("DNAME"))
+          .build();
+    };
+
+    // verify plan
+    relFn(relFn)
+        .withRule(CoreRules.PROJECT_TO_SEMI_JOIN)
+        .check();
+
+    // verify hint
+    final RelBuilder relBuilder = RelBuilder.create(RelBuilderTest.config().build());
+    final RelNode input = relFn.apply(relBuilder);
+    final HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(CoreRules.PROJECT_TO_SEMI_JOIN)
+        .build();
+    final HepPlanner hepPlanner = new HepPlanner(program);
+    hepPlanner.setRoot(input);
+    final RelNode output = hepPlanner.findBestExp();

Review comment:
       Yes, it is deterministic. HepPlanner applies its rule(s) systematically until no rule can be fired.
   In this particular test it will simply apply {{CoreRules.PROJECT_TO_SEMI_JOIN}}.




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