jinxing64 commented on a change in pull request #1333: [CALCITE-3214] Add 
UnionToUnionRule for materialization matching.
URL: https://github.com/apache/calcite/pull/1333#discussion_r314573112
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/plan/MaterializedViewSubstitutionVisitor.java
 ##########
 @@ -180,6 +182,39 @@ public UnifyResult apply(UnifyRuleCall call) {
     }
   }
 
+  /**
+   * Implementation of {@link SubstitutionVisitor.UnifyRule} that matches a
+   * {@link MutableUnion} to a {@link MutableUnion} where the query and target
+   * have the same inputs but might not have the same order.
+   */
+  private static class UnionToUnionRule extends AbstractUnifyRule {
+    public static final UnionToUnionRule INSTANCE = new UnionToUnionRule();
+
+    private UnionToUnionRule() {
+      super(any(MutableUnion.class), any(MutableUnion.class), 0);
+    }
+
+    public UnifyResult apply(UnifyRuleCall call) {
+      final MutableUnion query = (MutableUnion) call.query;
+      final MutableUnion target = (MutableUnion) call.target;
+      List<MutableRel> queryInputs = query.getInputs();
+      List<MutableRel> targetInputs = target.getInputs();
+      if (queryInputs.size() == targetInputs.size()) {
+        while (!queryInputs.isEmpty()) {
 
 Review comment:
   Ah~ I got it~ Thanks ~ refine soon.

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


With regards,
Apache Git Services

Reply via email to