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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RefreshMTMVCommand.java:
##########
@@ -194,12 +197,31 @@ protected LogicalPlan createRefreshCommand(MTMV mtmv, 
StatementContext statement
                 
statementContext.setExcludedTriggerTables(mtmv.getExcludedTriggerTables());
                 return createIvmIncrRefreshManager().buildInsertCommand(mtmv);
             case COMPLETE:
+                
statementContext.setExcludedTriggerTables(mtmv.getExcludedTriggerTables());
+                Set<String> completeRefreshPartitions = 
getCompleteRefreshPartitions(mtmv);
+                Map<TableIf, String> tableWithPartKey = 
getIncrementalTableMap(mtmv);
+                MTMVRefreshContext refreshContext = 
MTMVRefreshContext.buildContext(mtmv, Maps.newHashMap());

Review Comment:
   Fixed in `719596f06db`.
   
   The COMPLETE branch now pins before it derives: `pinBaseTableSnapshots` 
loads one `MvccSnapshot` per `MvccTable` of 
`relation.getBaseTablesOneLevelAndFromView()` (the same set 
`MTMVTask#beforeMTMVRefresh` pins), installs each on the explain 
`StatementContext` via `setSnapshot`, and hands the same map to 
`MTMVRefreshContext.buildContext`. The roll-up then resolves the pin for 
`getPartitionType`, `getPartitionColumns` and `generateRollUpPartitionKeyDesc`, 
so an input is materialized once per explain instead of once per base-partition 
descriptor. `UpdateMvByPartitionCommand.constructTableWithPredicates` reads 
`statementContext.getSnapshot(table)` and `getNameToPartitionItems(snapshot)`, 
so predicate construction and scan binding resolve that same pin -- including 
the Hive case where a remote DROP lands between the mapping enumeration and 
`from()`.
   
   `RefreshMTMVCommandTest#testCompleteExplainPinsOneSnapshotPerExternalInput` 
asserts `loadSnapshot` runs exactly once per external input, and that the same 
snapshot instances reach both `buildContext` and the statement context.
   
   Validation: `RefreshMTMVCommandTest` 15/15; full `./build.sh --fe`; 
regression 5 suites, 0 failed (`mtmv_p0`: test_mtmv_external_pct_read_scope, 
test_mtmv_external_pct_compensation, test_mtmv_base_partition_read_scope; 
`mtmv_p0/ivm`: test_ivm_absent_pct_input_read_scope, test_ivm_explain_refresh).
   



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