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 2019/11/03 05:45:28 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #1554: [CALCITE-3462] Add method in RelBuilder for conveniently projecting out expressions

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

 ##########
 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());
+    for (RexNode excludeExp : expressions) {
+      allExpressions.remove(excludeExp);
 
 Review comment:
   We may need to throw exception if the specified expression does not exist.

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


With regards,
Apache Git Services