seawinde commented on code in PR #66370:
URL: https://github.com/apache/doris/pull/66370#discussion_r3719027993


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java:
##########
@@ -1443,6 +1443,22 @@ public Map<BaseTableInfo, Collection<Partition>> 
getMvCanRewritePartitionsMap()
         return mvCanRewritePartitionsMap;
     }
 
+    /** Clear materialized-view planning state retained by a prepared 
statement between executions. */
+    public void resetMaterializedViewStateForPreparedExecution() {
+        tableUsedPartitionNameMap.clear();
+        commonTableIdToRelationIdToMap.clear();
+        mvCanRewritePartitionsMap.clear();
+        materializedViewRewriteDuration = 0;
+        hints.removeIf(UseMvHint.class::isInstance);

Review Comment:
   Fixed in 4dfcd7c5482. The per-external-EXECUTE reset removes 
InitMaterializationContextHook instances (including the DML subclass) while 
preserving unrelated planner hooks. Analysis can therefore re-add the hook only 
when the current session enables MV rewrite. ExecuteCommandTest verifies both 
MV-hook removal and unrelated-hook preservation; the focused FE UT passes (9 
tests, 0 failures).



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java:
##########
@@ -1443,6 +1443,22 @@ public Map<BaseTableInfo, Collection<Partition>> 
getMvCanRewritePartitionsMap()
         return mvCanRewritePartitionsMap;
     }
 
+    /** Clear materialized-view planning state retained by a prepared 
statement between executions. */
+    public void resetMaterializedViewStateForPreparedExecution() {
+        tableUsedPartitionNameMap.clear();
+        commonTableIdToRelationIdToMap.clear();
+        mvCanRewritePartitionsMap.clear();
+        materializedViewRewriteDuration = 0;
+        hints.removeIf(UseMvHint.class::isInstance);
+        tmpPlanForMvRewrite.clear();
+        rewrittenPlansByMv.clear();
+        needPreMvRewriteRuleMasks.clear();
+        needPreMvRewrite = false;
+        preMvRewritten = false;
+        materializationRewrittenSuccessSet.clear();
+        relationIdToStatisticsMap.clear();

Review Comment:
   Fixed in 4dfcd7c5482. The per-external-EXECUTE reset now clears 
candidateMTMVs, candidateMVs, and mtmvRelatedTables before the current planning 
pass rebuilds MV discovery state. ExecuteCommandTest seeds all three 
collections before each execution and verifies they are empty at the next 
planning boundary; the focused FE UT passes (9 tests, 0 failures).



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to