chunweilei commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r526573000



##########
File path: 
core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -113,19 +115,39 @@ public RelOptPredicateList getAllPredicates(TableScan 
scan, RelMetadataQuery mq)
   }
 
   /**
-   * Extract predicates for a project.
+   * Extracts predicates for a project.
    */
   public RelOptPredicateList getAllPredicates(Project project, 
RelMetadataQuery mq) {
     return mq.getAllPredicates(project.getInput());
   }
 
   /**
-   * Add the Filter condition to the list obtained from the input.
+   * Extracts predicates for a Filter.
    */
   public RelOptPredicateList getAllPredicates(Filter filter, RelMetadataQuery 
mq) {
-    final RelNode input = filter.getInput();
-    final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
-    final RexNode pred = filter.getCondition();
+    return getAllFilterPredicates(filter, mq, filter.getCondition());
+  }
+
+  /**
+   * Extracts predicates for a Calc.
+   */
+  public RelOptPredicateList getAllPredicates(Calc calc, RelMetadataQuery mq) {
+    final RexProgram rexProgram = calc.getProgram();
+    if (rexProgram.getCondition() != null) {
+      final RexNode condition = 
rexProgram.expandLocalRef(rexProgram.getCondition());
+      return getAllFilterPredicates(calc, mq, condition);
+    } else {
+      return mq.getAllPredicates(calc.getInput());
+    }
+  }
+
+  /**
+   * Add the Filter condition to the list obtained from the input.
+   */
+  public RelOptPredicateList getAllFilterPredicates(RelNode rel,
+      RelMetadataQuery mq, RexNode pred) {
+    final RelNode input = rel.getInput(0);

Review comment:
       Does this method have to be public? Maybe we should use private.




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