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 18:40:59 UTC

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

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



##########
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:
       I didn't touch this before so out of curiosity: 
   
   Is HepPlanner deterministic  that we can guarantee this test will not be flaky?




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