jinxing64 commented on a change in pull request #1554: [CALCITE-3462] Add 
method in RelBuilder for conveniently projecting out expressions
URL: https://github.com/apache/calcite/pull/1554#discussion_r355157239
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/tools/RelBuilder.java
 ##########
 @@ -1259,15 +1255,31 @@ public RelBuilder projectPlus(RexNode... nodes) {
     return projectPlus(ImmutableList.copyOf(nodes));
   }
 
-  /** Creates a {@link Project} of all original fields, plus the given list of
+  /** Creates a {@link Project} of all original fields, plus the given
    * expressions. */
   public RelBuilder projectPlus(Iterable<RexNode> nodes) {
     final ImmutableList.Builder<RexNode> builder = ImmutableList.builder();
     return project(builder.addAll(fields()).addAll(nodes).build());
   }
 
-  /** Creates a {@link Project} of the given list
-   * of expressions, using the given names.
+  /** Creates a {@link Project} of all original fields, minus the given
+   * expressions. */
+  public RelBuilder projectMinus(RexNode... expressions) {
+    return projectMinus(ImmutableList.copyOf(expressions));
+  }
+
+  /** Creates a {@link Project} of all original fields, minus the given
+   * expressions. */
+  public RelBuilder projectMinus(Iterable<RexNode> expressions) {
+    List<RexNode> allExpressions = new ArrayList<>(fields());
 
 Review comment:
   Since it's only valid to pass `expressions` as a list of `RexInputRef`. How 
about:
   1. We check the type of `expressions` -- only `RexInputRef` is valid
   2. Indexes of `RexInputRef` from `expressions` should be unique and smaller 
than `fields().size`
   
   By above two steps, I think we can save the exception below.

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


With regards,
Apache Git Services

Reply via email to