[fix](mtmv) Check MV partition coverage when union compensation is disabled #71138
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 381 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #71138"
general
weight: 0.35
morrySnow
Background
An asynchronous materialized view (MV) tracks freshness by partition. The optimizer can use fresh MV partitions and, when UNION ALL compensation is enabled, read missing partitions from the base table.
What problem does this PR solve?
Issue Number: None
Related PR: #49514 (introduced the partition-check gate)
PR Type: Bugfix
Problem Summary:
With
enable_materialized_view_union_rewrite=false, the optimizer could rewrite a query to scan a stale partition of a partially fresh MV. The rewrite now checks partition coverage before using the MV. A query covered by fresh partitions can still use the MV, and a query that needs data from a stale partition falls back to the base table when compensation is disabled.In the regression fixture, the MV contains
1and10. The base table receives an additional11in its second partition after the MV refresh.| Before the fix | With the fix |
|---|---|
|
11from the MV |22from the base table |Details
AbstractMaterializedViewRuleused the UNION switch to gate invalid-partition calculation. With the switch off, it could admit an MV scan with incomplete coverage.PartitionCompensatorTestandPartitionCompensatorBatchTestcover partition calculation. Thegrace_periodandpartition_curd_union_rewritesuites cover freshness and compensation with the switch enabled.branch-3.1,branch-4.0,branch-4.1, andbranch-4.2by source inspection.Testing
partition_freshness_without_unionfailed the base-table plan assertion on the unmodified master baseline and passed with the fix. With UNION compensation disabled, the fresh-only query scanned one MV partition and returned1. The stale-only and full-table queries scanned the base table and returned21and22.availabilityandunion_rewritedirectories in shared-nothing mode. The Hive-dependent suite was excluded.Release note
With UNION compensation disabled, queries that need a stale asynchronous MV partition now read current data from the base table. Queries covered by fresh MV partitions remain eligible for MV rewrite.
Check List (For Author)