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/04/21 17:42:38 UTC

[GitHub] [calcite] hbtoo commented on a change in pull request #1927: [CALCITE-3939] Change UnionEliminatorRule and ProjectRemoveRule to auto pruning SubstitutionRule

hbtoo commented on a change in pull request #1927:
URL: https://github.com/apache/calcite/pull/1927#discussion_r412360659



##########
File path: core/src/main/java/org/apache/calcite/rel/rules/UnionEliminatorRule.java
##########
@@ -44,18 +46,17 @@ public UnionEliminatorRule(Class<? extends Union> clazz,
 
   //~ Methods ----------------------------------------------------------------
 
-  public void onMatch(RelOptRuleCall call) {
+  @Override public boolean matches(RelOptRuleCall call) {
     Union union = call.rel(0);
-    if (union.getInputs().size() != 1) {
-      return;
-    }
-    if (!union.all) {
-      return;
-    }
-
-    // REVIEW jvs 14-Mar-2006:  why don't we need to register
-    // the equivalence here like we do in AggregateRemoveRule?
+    return union.all && union.getInputs().size() == 1;

Review comment:
       I guess one possible case is this. Unions are typically created via:
   public static LogicalUnion create(List<RelNode> inputs, boolean all);
   
   "List<RelNode> inputs" is typically assembled with a for loop. Whenever the for loop executes with only one loop, we have an input list of one element. 




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