chunweilei 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_r344660105
##########
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:
Agree with @danny0405 's comment.
----------------------------------------------------------------
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