You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/05/17 01:54:20 UTC

[GitHub] [calcite] xy2953396112 opened a new pull request #1983: [CALCITE-4005] Support calc operator in RelMdAllPredicates and RelMdE…

xy2953396112 opened a new pull request #1983:
URL: https://github.com/apache/calcite/pull/1983


   …xpressionLineage (Xu Zhaohui)
   https://issues.apache.org/jira/browse/CALCITE-4005


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on pull request #1983: [CALCITE-4005] Support calc operator in RelMdAllPredicates and RelMdE…

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#issuecomment-645837559


   @chunweilei  Please help review this pr when you have time. Thanks a lot.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r524146461



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -120,12 +124,35 @@ public RelOptPredicateList getAllPredicates(Project project, RelMetadataQuery mq
   }
 
   /**
-   * Add the Filter condition to the list obtained from the input.
+   * Extract 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());
+  }
+
+  /**
+   * Extract predicates for a Calc.
+   */
+  public RelOptPredicateList getAllPredicates(Calc calc, RelMetadataQuery mq) {
+    final RexProgram rexProgram = calc.getProgram();
+    List<RexNode> condition = new ArrayList<>();
+    if (rexProgram.getCondition() != null) {
+      condition = Util.transform(ImmutableList.of(rexProgram.getCondition()),
+          rexProgram::expandLocalRef);
+    } else {
+      return mq.getAllPredicates(calc.getInput());

Review comment:
       Thanks, update the code.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 edited a comment on pull request #1983: [CALCITE-4005] Support calc operator in RelMdAllPredicates and RelMdE…

Posted by GitBox <gi...@apache.org>.
xy2953396112 edited a comment on pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#issuecomment-645837559


   @chunweilei  Please help review this pr when you have time. Thanks.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r524145966



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -120,12 +124,35 @@ public RelOptPredicateList getAllPredicates(Project project, RelMetadataQuery mq
   }
 
   /**
-   * Add the Filter condition to the list obtained from the input.
+   * Extract 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());
+  }
+
+  /**
+   * Extract predicates for a Calc.
+   */
+  public RelOptPredicateList getAllPredicates(Calc calc, RelMetadataQuery mq) {
+    final RexProgram rexProgram = calc.getProgram();
+    List<RexNode> condition = new ArrayList<>();

Review comment:
       ok




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] chunweilei commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [calcite] yanlin-Lynn merged pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn merged pull request #1983:
URL: https://github.com/apache/calcite/pull/1983


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] yanlin-Lynn commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r527346612



##########
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.
+   */
+  private RelOptPredicateList getAllFilterPredicates(RelNode rel,
+      RelMetadataQuery mq, RexNode pred) {
+    final RelNode input = rel.getInput(0);

Review comment:
       How about just use rel, not rel.getInput(0) ?
   And add the doc, the pred comes from the parent of rel.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r527383309



##########
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);

Review comment:
       ok,Thanks




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] yanlin-Lynn commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r527346752



##########
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);

Review comment:
       How about `getAllFilterPredicates(calc.getInput(0), mq, condition)`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] chunweilei commented on a change in pull request #1983: [CALCITE-4005] Support calc operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r524080533



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -120,12 +124,35 @@ public RelOptPredicateList getAllPredicates(Project project, RelMetadataQuery mq
   }
 
   /**
-   * Add the Filter condition to the list obtained from the input.
+   * Extract 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());
+  }
+
+  /**
+   * Extract predicates for a Calc.
+   */
+  public RelOptPredicateList getAllPredicates(Calc calc, RelMetadataQuery mq) {
+    final RexProgram rexProgram = calc.getProgram();
+    List<RexNode> condition = new ArrayList<>();
+    if (rexProgram.getCondition() != null) {
+      condition = Util.transform(ImmutableList.of(rexProgram.getCondition()),
+          rexProgram::expandLocalRef);
+    } else {
+      return mq.getAllPredicates(calc.getInput());

Review comment:
       The type of `condition` can be RexNode rather than List<RexNode>.

##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -120,12 +124,35 @@ public RelOptPredicateList getAllPredicates(Project project, RelMetadataQuery mq
   }
 
   /**
-   * Add the Filter condition to the list obtained from the input.
+   * Extract 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());
+  }
+
+  /**
+   * Extract predicates for a Calc.
+   */
+  public RelOptPredicateList getAllPredicates(Calc calc, RelMetadataQuery mq) {
+    final RexProgram rexProgram = calc.getProgram();
+    List<RexNode> condition = new ArrayList<>();

Review comment:
       Extract -> Extracts




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r527361088



##########
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.
+   */
+  private RelOptPredicateList getAllFilterPredicates(RelNode rel,
+      RelMetadataQuery mq, RexNode pred) {
+    final RelNode input = rel.getInput(0);

Review comment:
       `rel` used in `getAllFilterPredicates` rather than only used for `getInput()`.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] chunweilei commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r525910610



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -113,19 +115,40 @@ 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();
+    RexNode condition = null;
+    if (rexProgram.getCondition() != null) {
+      condition = rexProgram.expandLocalRef(rexProgram.getCondition());
+    } else {
+      return mq.getAllPredicates(calc.getInput());
+    }
+    return getAllFilterPredicates(calc, mq, condition);
+  }

Review comment:
       You can put `return getAllFilterPredicates(calc, mq, condition);` in the if conditiion.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r525948729



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdAllPredicates.java
##########
@@ -113,19 +115,40 @@ 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();
+    RexNode condition = null;
+    if (rexProgram.getCondition() != null) {
+      condition = rexProgram.expandLocalRef(rexProgram.getCondition());
+    } else {
+      return mq.getAllPredicates(calc.getInput());
+    }
+    return getAllFilterPredicates(calc, mq, condition);
+  }

Review comment:
       > You can put `return getAllFilterPredicates(calc, mq, condition);` in the if conditiion.
   
   Thanks.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [calcite] xy2953396112 commented on a change in pull request #1983: [CALCITE-4005] Support Calc and SetOp operator in RelMdAllPredicates

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #1983:
URL: https://github.com/apache/calcite/pull/1983#discussion_r526574744



##########
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:
       you are right. update the code.




----------------------------------------------------------------
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:
users@infra.apache.org