github-actions[bot] commented on code in PR #66795:
URL: https://github.com/apache/doris/pull/66795#discussion_r4423216901


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java:
##########
@@ -220,6 +225,23 @@ protected List<Plan> doRewrite(StructInfo queryStructInfo, 
CascadesContext casca
             MaterializationContext materializationContext) throws 
AnalysisException {
         List<Plan> rewriteResults = new ArrayList<>();

Review Comment:
   [P1] Reject cache-guarded TopN ordering before MV matching
   
   `containsCacheGuardInRowAffectingExpressions` handles filters, joins, 
aggregates, sorts, and windows, but skips `LogicalTopN`. A guarded 
`date_trunc(timestamptz_col, 'day')` used as `ORDER BY ... LIMIT` is therefore 
allowed to rewrite even though the MV selected its rows under the creation time 
zone; a query in another zone can select a different row. Include 
`LogicalTopN.getOrderKeys()` in the row-affecting guard scan and add a 
cross-zone TopN regression.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SessionVarGuardRewriter.java:
##########
@@ -74,55 +140,198 @@ private Plan rewritePlanNode(Plan plan) {
         return plan;
     }
 
-    private static class ReplaceRule implements ExpressionPatternRuleFactory {
+    /**

Review Comment:
   [P1] Do not let the sync-MV SQL-mode shortcut ignore current-only variables
   
   `computeGuardMask` marks a current-only plan variable such as 
`enable_decimal256` as `GUARD_OTHER`, but `checkSessionVariablesMatchForSyncMv` 
first calls `checkSessionVariablesMatch`, which iterates only persisted keys 
and returns true before its key-set check. `computeSyncMvGuardMask` therefore 
returns `GUARD_NONE` for an older sync-MV map missing that variable, even 
though decimal expressions may have been materialized with different 
precision/overflow semantics. Check key-set equality before the shortcut (or 
make the shortcut use the union comparison), and add a current-only 
historical-map test.



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