mihaibudiu commented on code in PR #4346:
URL: https://github.com/apache/calcite/pull/4346#discussion_r2067475048


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##########
@@ -966,15 +986,18 @@ protected EquivalenceFinder() {
      * b + b + e
      * </pre>
      */
-    class ExprsItr implements Iterator<Mapping> {
+    static class ExprsItr implements Iterator<Mapping> {
       final int[] columns;
       final BitSet[] columnSets;
       final int[] iterationIdx;
       @Nullable Mapping nextMapping;
       boolean firstCall;
+      int sourceCount;
+      int targetCount;
 
       @SuppressWarnings("JdkObsolete")
-      ExprsItr(ImmutableBitSet fields) {
+      ExprsItr(ImmutableBitSet fields, Map<Integer, BitSet> equivalence,

Review Comment:
   is the supression of JdkObsolete still necessary?



##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##########
@@ -218,8 +214,30 @@ public RelOptPredicateList getPredicates(Project project,
     for (RexNode r : inputInfo.pulledUpPredicates) {
       RexNode r2 = projectPredicate(rexBuilder, input, r, columnsMapped);
       if (!r2.isAlwaysTrue()) {
-        r2 = r2.accept(new RexPermuteInputsShuttle(m, input));
-        projectPullUpPredicates.add(r2);
+        ImmutableBitSet fields = RelOptUtil.InputFinder.bits(r2);
+        // If r2 cannot find input (such as SubQuery),
+        // it will directly return without adjusting mapping.
+        if (fields.isEmpty()) {
+          projectPullUpPredicates.add(r2);
+          continue;
+        }
+        // Using Map<Integer, BitSet>, the result will be

Review Comment:
   There is no need to describe alternative designs.
   I would change this comment and add it to the declaration of the map itself, 
above.
   I would document the map: keys are field indexes (RexInputRef) that appear 
in the project, values are sets of field indexes (RexInputRef) that appear in 
r2.



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