hsyuan commented on a change in pull request #1995:
URL: https://github.com/apache/calcite/pull/1995#discussion_r435714138



##########
File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
##########
@@ -100,6 +106,45 @@ public static EnumerableHashJoin create(
         condition, variablesSet, joinType);
   }
 
+  @Override public Pair<RelTraitSet, List<RelTraitSet>> passThroughTraits(
+      final RelTraitSet required) {
+    RelCollation collation = required.getCollation();
+    if (collation == null
+        || collation == RelCollations.EMPTY
+        || joinType == JoinRelType.FULL
+        || joinType == JoinRelType.RIGHT) {
+      return null;
+    }
+
+    List<Integer> requiredKeys = RelCollations.ordinals(collation);
+    ImmutableBitSet requiredKeySet = ImmutableBitSet.of(requiredKeys);
+    ImmutableBitSet leftKeySet = ImmutableBitSet.of(joinInfo.leftKeys);
+
+    // EnumerableHashJoin traits passdown shall only pass through collation to 
left input.
+    // It is because for EnumerableHashJoin always builds hash table on right 
input,
+    // and only non-hashed side can preserve ordering.
+
+    // Only consider exact key match for now
+    if (requiredKeySet.equals(leftKeySet)) {
+      RelTraitSet passthroughTraitSet = traitSet.replace(collation);
+      return Pair.of(passthroughTraitSet,
+          ImmutableList.of(
+              passthroughTraitSet,
+              passthroughTraitSet.replace(RelCollations.EMPTY)));
+    }
+
+    // TODO: consider super keyset and sub keyset
+    return null;
+  }
+
+  @Override public DeriveMode getDeriveMode() {
+    if (joinType == JoinRelType.FULL || joinType == JoinRelType.RIGHT) {
+      return DeriveMode.PROHIBITED;
+    }
+
+    return DeriveMode.BOTH;

Review comment:
       I need to consider refining the java doc to make it easier to understand.




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