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



##########
File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java
##########
@@ -131,8 +160,35 @@ public static boolean isMergeJoinSupported(JoinRelType 
joinType) {
           required, ImmutableList.of(
           required.replace(leftCollation),
           required.replace(rightCollation)));
+    } else if (isSubset(reqKeys, rightKeys)) {
+      // if sort keys are subset of right join keys, we can extend collations 
to make sure all join
+      // keys are sorted.
+      collation = extendCollation(collation, rightKeys);
+      RelCollation rightCollation = RelCollations.shift(collation,
+          -left.getRowType().getFieldCount());
+      Mappings.TargetMapping invMapping = mapping.inverse();
+      RelCollation leftCollation = RexUtil.apply(invMapping, rightCollation);
+      return Pair.of(
+          required, ImmutableList.of(
+              required.replace(leftCollation),
+              required.replace(rightCollation)));
+    } else if (isPrefixOrderingNotRequired(rightKeys, reqKeys)
+        && allElementsGe(reqKeys, getLeft().getRowType().getFieldCount())) {

Review comment:
       Done! Thanks!




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

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


Reply via email to