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



##########
File path: core/src/main/java/org/apache/calcite/rel/RelDistributions.java
##########
@@ -135,10 +141,14 @@ public RelDistribution apply(Mappings.TargetMapping 
mapping) {
       if (keys.isEmpty()) {
         return this;
       }
-      return getTraitDef().canonize(
-          new RelDistributionImpl(type,
-              ImmutableIntList.copyOf(
-                  Mappings.apply2((Mapping) mapping, keys))));
+      for (int key : keys) {
+        if (mapping.getTargetOpt(key) == -1) {

Review comment:
       Key might be greater than / equal with `mapping.sourceCount` (out of 
range). Haven't try to reproduce here in Calcite. Perhaps we can also add a 
check in `TargetMapping.getTargetOpt()` of implementation class, if the `key >= 
sourceCount`, also return -1.




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