You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ji...@apache.org on 2023/06/29 13:08:14 UTC

[calcite] branch main updated: [MINOR] Assert can be replaced in `AbstractMaterializedViewRule#perform()`

This is an automated email from the ASF dual-hosted git repository.

jiajunxie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new aff0fc981b [MINOR] Assert can be replaced in `AbstractMaterializedViewRule#perform()`
aff0fc981b is described below

commit aff0fc981b4bd76680aa5d92c20ef98b84cd5304
Author: xiejiajun <ji...@foxmail.com>
AuthorDate: Sun Jun 11 10:20:15 2023 +0800

    [MINOR] Assert can be replaced in `AbstractMaterializedViewRule#perform()`
---
 .../calcite/rel/rules/materialize/MaterializedViewRule.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java b/core/src/main/java/org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java
index 4a7f101e23..0ce1de86da 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java
@@ -365,7 +365,7 @@ public abstract class MaterializedViewRule<C extends MaterializedViewRule.Config
                   currQEC, queryPreds, queryBasedVEC, viewPreds,
                   queryToViewTableMapping);
           if (compensationPreds == null && config.generateUnionRewriting()) {
-            // Attempt partial rewriting using union operator. This rewriting
+            // a. Attempt partial rewriting using union operator. This rewriting
             // will read some data from the view and the rest of the data from
             // the query computation. The resulting predicates are expressed
             // using {@link RexTableInputRef} over the view.
@@ -379,8 +379,11 @@ public abstract class MaterializedViewRule<C extends MaterializedViewRule.Config
             }
             RexNode compensationColumnsEquiPred = compensationPreds.left;
             RexNode otherCompensationPred = compensationPreds.right;
-            assert !compensationColumnsEquiPred.isAlwaysTrue()
-                || !otherCompensationPred.isAlwaysTrue();
+            if (compensationColumnsEquiPred.isAlwaysTrue()
+                && otherCompensationPred.isAlwaysTrue()) {
+              // Skip it
+              continue;
+            }
 
             // b. Generate union branch (query).
             final RelNode unionInputQuery =
@@ -419,7 +422,7 @@ public abstract class MaterializedViewRule<C extends MaterializedViewRule.Config
             RexNode compensationColumnsEquiPred = compensationPreds.left;
             RexNode otherCompensationPred = compensationPreds.right;
 
-            // a. Compute final compensation predicate.
+            // A. Compute final compensation predicate.
             if (!compensationColumnsEquiPred.isAlwaysTrue()
                 || !otherCompensationPred.isAlwaysTrue()) {
               // All columns required by compensating predicates must be contained
@@ -456,7 +459,7 @@ public abstract class MaterializedViewRule<C extends MaterializedViewRule.Config
                     ImmutableList.of(compensationColumnsEquiPred,
                         otherCompensationPred));
 
-            // b. Generate final rewriting if possible.
+            // B. Generate final rewriting if possible.
             // First, we add the compensation predicate (if any) on top of the view.
             // Then, we trigger the unifying method. This method will either create a
             // Project or an Aggregate operator on top of the view. It will also compute