keatoooon commented on code in PR #3452:
URL: https://github.com/apache/calcite/pull/3452#discussion_r1346428283


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##########
@@ -666,6 +666,29 @@ static class JoinConditionBasedPredicateInference {
       equivalence = BitSets.closure(equivalence);
     }
 
+    /**
+     * As RexPermuteInputsShuttle, with one exception. When visiting an 
inputRef,
+     * it will replace the type of the InputRef with the type found in the 
input fields,
+     * instead of keeping the original type. This is used within
+     * when generating the Left/RightInferredPredicates, to avoid nullability 
mismatches
+     * between the types of the join and the types of the inputs.
+     */
+    private class TypeChangingRexPermuteInputsShuttle
+        extends org.apache.calcite.rex.RexPermuteInputsShuttle {

Review Comment:
   I tried doing something like this in `RexPermuteInputsShuttle` 
   
   ```
   if (fields.isEmpty()) {
         return new RexInputRef(
             target,
             local.getType());
       } else {
         return new RexInputRef(
             target,
             fields.get(target).getType());
       }
   ```
   (Note that the if statement is needed because it's valid to create a 
`RexPermuteInputsShuttle` without any backing fields.)
   
   This caused several tests to fail with index out of bound errors. The reason 
wasn't obvious to me. I'll do a bit of poking around and see if I can figure 
out why.
   
   



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to