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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit e602048f737e7c8950afbd05de9ab22b54a61242
Author: 谢健 <jianx...@gmail.com>
AuthorDate: Sat May 11 16:07:13 2024 +0800

    [fix](Nereids) Fix materialized view rule to check struct info validity 
(#34665)
    
    This PR improves the materialized view rule by adding additional validity 
checks for the struct info. The changes include:
    
      1. In AbstractMaterializedViewRule.java:
        * Modified the checkPattern method to also check the validity of the 
struct info using context.getStructInfo().isValid().
        * Updated the error message for invalid struct info to include the view 
plan string for better debugging.
    
      2. In StructInfo.java:
        * Enhanced the isValid() method to ensure that all nodes in the hyper 
graph have non-null expressions, in addition to the existing validity check.
    
    These changes ensure that the materialized view rule properly validates the 
struct info before proceeding with the optimization. It prevents invalid struct 
info from being used and provides more detailed error messages for debugging 
purposes.
    
    The additional validity check in StructInfo.isValid() verifies that all 
nodes in the hyper graph have non-null expressions, which is necessary for the 
materialized view rule to function correctly.
    
    By incorporating these validity checks, the materialized view rule becomes 
more robust and can handle invalid struct info gracefully, improving the 
overall stability and reliability of the optimization process.
---
 .../nereids/rules/exploration/mv/AbstractMaterializedViewRule.java   | 5 +++--
 .../org/apache/doris/nereids/rules/exploration/mv/StructInfo.java    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

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 6d0f6027066..7a08797ca55 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
@@ -108,7 +108,8 @@ public abstract class AbstractMaterializedViewRule 
implements ExplorationRuleFac
                 continue;
             }
             // check mv plan is valid or not
-            if (!checkPattern(context.getStructInfo())) {
+            boolean valid = checkPattern(context.getStructInfo()) && 
context.getStructInfo().isValid();
+            if (!valid) {
                 context.recordFailReason(context.getStructInfo(),
                         "View struct info is invalid", () -> String.format(", 
view plan is %s",
                                 
context.getStructInfo().getOriginalPlan().treeString()));
@@ -145,7 +146,7 @@ public abstract class AbstractMaterializedViewRule 
implements ExplorationRuleFac
         List<StructInfo> uncheckedStructInfos = 
MaterializedViewUtils.extractStructInfo(queryPlan, cascadesContext,
                 materializedViewTableSet);
         uncheckedStructInfos.forEach(queryStructInfo -> {
-            boolean valid = checkPattern(queryStructInfo);
+            boolean valid = checkPattern(queryStructInfo) && 
queryStructInfo.isValid();
             if (!valid) {
                 cascadesContext.getMaterializationContexts().forEach(ctx ->
                         ctx.recordFailReason(queryStructInfo, "Query struct 
info is invalid",
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
index 757004071ee..b617cdfe701 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
@@ -122,7 +122,8 @@ public class StructInfo {
         this.originalPlan = originalPlan;
         this.originalPlanId = originalPlanId;
         this.hyperGraph = hyperGraph;
-        this.valid = valid;
+        this.valid = valid
+                && hyperGraph.getNodes().stream().allMatch(n -> 
((StructInfoNode) n).getExpressions() != null);
         this.topPlan = topPlan;
         this.bottomPlan = bottomPlan;
         this.relations = relations;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to