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

englefly pushed a commit to branch fix/4.2-cp-nullable-expr-id
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 5fa7b052b8a1f509d915bae76cb11aa635537702
Author: minghong <[email protected]>
AuthorDate: Fri Oct 30 00:03:36 2026 +0800

    [fix](rbo) Accept constant query outputs when matching a materialized view
    
    ### What problem does this PR solve?
    
    Issue Number: None
    
    Problem Summary:
    
    The materialized view matching requires every query expression to have a 
counterpart in the view.
    A constant expression needs none: the query column may be pinned to a 
literal by a predicate, or
    materialized as a constant above an aggregate, and the view does not have 
to output it. Treat every
    constant (not only a literal) as having no view counterpart, which also 
covers the constant aliases
    produced by constant propagation.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test: Regression test (the mv suites)
    - Behavior changed: No
    - Does this need documentation: No
---
 .../nereids/rules/exploration/mv/AbstractMaterializedViewRule.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java
index 768801f8bf6..ba4b0a1b370 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java
@@ -595,7 +595,10 @@ public abstract class AbstractMaterializedViewRule 
implements ExplorationRuleFac
         List<Expression> rewrittenExpressions = new ArrayList<>();
         for (int exprIndex = 0; exprIndex < sourceShuttledExpressions.size(); 
exprIndex++) {
             Expression expressionShuttledToRewrite = 
sourceShuttledExpressions.get(exprIndex);
-            if (expressionShuttledToRewrite instanceof Literal) {
+            if (expressionShuttledToRewrite.isConstant()) {
+                // a constant expression needs no counterpart in the view: 
e.g. the query column is pinned to a
+                // literal by a predicate, or it is materialized as a constant 
above an aggregate, so the view does
+                // not have to output it
                 rewrittenExpressions.add(expressionShuttledToRewrite);
                 continue;
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to