github-actions[bot] commented on code in PR #66795:
URL: https://github.com/apache/doris/pull/66795#discussion_r4435355030
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java:
##########
@@ -1072,6 +1111,152 @@ protected boolean checkIfRewritten(Plan plan,
MaterializationContext context) {
&&
context.alreadyRewrite(plan.getGroupExpression().get().getOwnerGroup().getGroupId());
}
+ /**
+ * Whether the materialized view plan carries a cache guard in a row-set /
grouping / ordering
+ * affecting position: a filter or join predicate (including a mark-join
conjunct), a HAVING
+ * predicate, a group-by key (including the grouping-set keys of a
repeat), an order-by key or a window
+ * partition/order key. Such a guard means the materialized rows / groups
were derived with the
+ * creation session semantics, so a query in a different session can never
compensate them and the
+ * rewrite must be rejected regardless of which outputs the query selects.
+ */
Review Comment:
[P1] Trace cache guards through internal project aliases used by row
filters. `containsCacheGuardInRowAffectingExpressions` sees only the filter's
`SlotReference` (`d = boundary`) and never follows it to the producer
`Project(cacheGuard(date_trunc(ts, 'day')) AS d)`. If the MV returns only
`count(*)`, `MaterializationContext` maps visible outputs only, so
`guardedScanSlots()` is empty and `rewrittenPlanReadsGuardedOutput()` accepts
the rewrite. A cross-zone query can then reuse the count of rows selected under
the MV creation zone. Propagate cache-guard provenance through project/slot
lineage, including nested subqueries, or reject row-affecting slots whose
producers contain a cache guard.
--
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]