danny0405 commented on a change in pull request #2664:
URL: https://github.com/apache/calcite/pull/2664#discussion_r785614419



##########
File path: core/src/test/java/org/apache/calcite/test/SqlHintsConverterTest.java
##########
@@ -771,14 +788,42 @@ static HintStrategyTable 
createHintStrategies(HintStrategyTable.Builder builder)
                         + "allowed options: [ONE_PHASE, TWO_PHASE]",
                     hint.hintName)).build())
         .hintStrategy("use_hash_join",
-          HintPredicates.and(HintPredicates.JOIN, joinWithFixedTableName()))
+          HintPredicates.or(
+              HintPredicates.and(HintPredicates.CORRELATE, 
temporalJoinWithFixedTableName()),
+              HintPredicates.and(HintPredicates.JOIN, 
joinWithFixedTableName())))
         .hintStrategy("use_merge_join",
             HintStrategy.builder(
                 HintPredicates.and(HintPredicates.JOIN, 
joinWithFixedTableName()))
                 .excludedRules(EnumerableRules.ENUMERABLE_JOIN_RULE).build())
         .build();
     }
 
+    /** Returns a {@link HintPredicate} for temporal join with specified table 
references. */
+    private static HintPredicate temporalJoinWithFixedTableName() {
+      return (hint, rel) -> {
+        if (!(rel instanceof LogicalCorrelate)) {
+          return false;
+        }
+        LogicalCorrelate correlate = (LogicalCorrelate) rel;
+        RelNode leftInput = correlate.getLeft();
+        if (!(leftInput instanceof TableScan)) {
+          return false;
+        }
+        RelNode rightInput = correlate.getRight();
+        boolean rightIsFilterOnSnapshot = rightInput instanceof Filter
+            && ((Filter) rightInput).getInput() instanceof Snapshot
+            && ((Snapshot) ((Filter) rightInput).getInput()).getInput() 
instanceof TableScan;
+        if (!rightIsFilterOnSnapshot) {
+          return false;
+        }
+        String leftTableName = getTableNameOfScan(leftInput);
+        String rightTableName = getTableNameOfScan(
+            ((Snapshot) ((Filter) rightInput).getInput()).getInput());
+        final List<String> tableNames = hint.listOptions;
+        return tableNames.contains(leftTableName) && 
tableNames.contains(rightTableName);
+      };

Review comment:
       Can we use `equalsStringList` 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to