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:
   Reworked in 3daed42, without carrying a reset scope. A complete refresh is 
not one plan: it may be split into batches, whose later ones read non-PCT 
tables at the stream offset (SNAPSHOT) and read tables the MV partitions by as 
ordinary scans. One EXPLAIN statement stands for the refresh as a whole, so it 
now shows the read the refresh starts with: `IvmFullRefreshMTMV` plans every 
base table it reads through a stream with RESET under EXPLAIN, including the 
tables the MV partitions by, over the partitions the plan selects. Resolving 
the mapped reset scope would only be exact for a whole-MV refresh that fits in 
one batch, while adding metadata work to the explain path, so the mode is 
unified instead and the javadoc/PR state the contract. 
`IvmFullRefreshMTMVTest#testExplainFullRefreshResetsATableTheMvPartitionsBy` 
covers the partitioned-table path.
   



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