yujun777 commented on code in PR #69851:
URL: https://github.com/apache/doris/pull/69851#discussion_r4419800603


##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/ivm/IvmRewriteContext.java:
##########
@@ -163,11 +163,19 @@ public static IvmRewriteContext incrementalDryRun(MTMV 
mtmv, Optional<IvmDryRunL
                 Collections.emptyMap());
     }
 
-    /** EXPLAIN REFRESH COMPLETE: only a plan is produced. */
+    /**
+     * EXPLAIN REFRESH COMPLETE: only a plan is produced, and it is the plan a 
whole-MV COMPLETE
+     * refresh runs. That refresh reads every base table it does not partition 
by with
+     * {@link StreamReadMode#RESET} (MTMVTask#executePartitionBasedRefresh 
picks the mode: RESET for
+     * the first batch of a whole-MV refresh, SNAPSHOT afterwards), so a 
context that left the mode
+     * empty would plan the normalized query over ordinary base scans -- a 
different plan from the
+     * one the refresh executes. A refresh split into batches continues with 
SNAPSHOT for the later
+     * ones, which one EXPLAIN statement cannot show.
+     */
     public static IvmRewriteContext fullExplain(MTMV mtmv) {
         return new IvmRewriteContext(Mode.FULL, Objects.requireNonNull(mtmv, 
"mtmv can not be null"),
-                null, false, ExecutionKind.EXPLAIN, Optional.empty(), 
Collections.emptyMap(), Optional.empty(),
-                Collections.emptyMap());
+                null, false, ExecutionKind.EXPLAIN, Optional.empty(), 
Collections.emptyMap(),
+                Optional.of(StreamReadMode.RESET), Collections.emptyMap());

Review Comment:
   Addressed in 96e86d6. `fullExplain` now also carries the reset partition 
scope: the explain path maps the MV partitions it refreshes to base partitions 
with `MTMVPartitionUtil.collectPctResetPartitionIds` (the same helper 
`MTMVTask` now calls, moved out of the task so the two cannot drift), so 
`IvmFullRefreshMTMV` rewrites PCT base tables through RESET stream scans over 
the mapped partitions. Added 
`IvmFullRefreshMTMVTest#testExplainFullRefreshResetsThePartitionsOfThePartitionedBaseTable`
 for that path. Note the scope is the union over all MV partitions, since one 
EXPLAIN statement stands for the whole refresh while a real refresh may split 
it into batches.
   



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