yujun777 commented on code in PR #71190:
URL: https://github.com/apache/doris/pull/71190#discussion_r4750794692
##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java:
##########
@@ -156,6 +164,144 @@ public static ConnectContext createMTMVContext(MTMV mtmv,
List<RuleType> disable
return ctx;
}
+ /**
+ * Create an internal MTMV context for refresh execution, dry run, or
EXPLAIN REFRESH.
+ * Explicit REFRESH SET_VAR hints are applied on top of MTMV defaults so
they take
+ * precedence over both MTMV defaults and MV query SQL SET_VAR hints.
Materialized view
+ * rewrite remains forcibly disabled to prevent self-rewrite during
refresh and keep
+ * REFRESH, DRY RUN, and EXPLAIN REFRESH behavior consistent.
+ */
+ public static ConnectContext createMTMVRefreshContext(MTMV mtmv,
List<RuleType> disableRules,
+ @Nullable Map<String, String> refreshSessionVariables) {
+ ConnectContext previousContext = ConnectContext.get();
+ ConnectContext ctx = createMTMVContext(mtmv, disableRules);
+ try {
+ applyRefreshSessionVariables(ctx, null, refreshSessionVariables);
Review Comment:
Fixed in 6aa2d455853. Extended the pre-flight check in
`MTMVPlanUtil.applyRefreshSessionVariables` to reject any session variable
whose `@VarAttr` sets `affectQueryResultInPlan` or
`affectQueryResultInExecution` (such as `time_zone`, `sql_mode`,
`sql_select_limit`, `skip_delete_*`, `enable_strict_cast`) before mutating any
state, keeping IVM incremental retractions, partition refreshes, and
transparent MV rewrite consistent with the stored baseline. Added unit test
coverage in
`RefreshMTMVInfoAnalyzeTest.testAnalyzeResultAffectingSessionVarRejected` and
an end-to-end IVM UPDATE/DELETE retraction regression case in
`mtmv_p0/test_refresh_mtmv_hint`.
--
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]