[fix](mtmv) Reanalyze partition expressions using MV output columns #70289
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 545 lines diff across 6 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.377
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #70289"
general
weight: 0.35
morrySnow
Background
A partitioned asynchronous materialized view persists both its MV output partition column name (
partitionCol) and the inferred base-table partition expression (expr, e.g.,date_trunc(base_col, 'day')). When a base table undergoes a schema change, MV refresh reanalyzes the saved query and validates column and partition compatibility against the stored metadata.What problem does this PR solve?
Issue Number: None
Related PR: #56423 (introduced refresh-time partition reanalysis)
PR Type: Bugfix
Problem Summary:
After a compatible base-table schema change (such as widening a non-partition
VARCHARcolumn), an asynchronous materialized view created with an aliased date partition column (for examplePARTITION BY (trx_date) AS SELECT date_trunc(dt, 'day') AS trx_date, v FROM src, or aUNION ALLover multiple base tables unified astrx_date) fails refresh withpartition column can not find from sql select column. Reanalysis now uses the stored MV output partition column and truncation unit directly instead of parsing the stored base-table lineage expression back as a query output reference.Details
MTMVPlanUtil.javaandMTMVPartitionDefinition.java, +70/-16 lines) and 1 FE unit test file (MTMVPartitionReanalysisTest.java, 234 lines).EXPR-partitioned MV whose base-table partition column name differs from the MV output partition column alias.MTMVPlanUtil.analyzeQueryWithSql()convertedmvPartitionInfo.getExpr()(which references the base-table column name) to SQL and re-parsed it asMTMVPartitionDefinition.functionCallExpression.MTMVPartitionDefinitionthen looked up that base-table column name in the MV query's top-level output slots, which only expose the MV alias (trx_date).MTMVPlanUtilTestcases did not coverEXPR-partitioned MVs with aliaseddate_truncoutput columns undergoing schema-change reanalysis.- Add
MTMVPartitionDefinition.forReanalysis(MTMVPartitionInfo)and call it fromMTMVPlanUtil.analyzeQueryWithSql(), passing the stored MV outputpartitionColanddate_trunctimeUnitdirectly without SQL round-tripping.- During
EXPRreanalysis inMTMVPartitionDefinition.getRelatedTableInfos(), first tracepartitionColwithout adding a redundant outerdate_truncand reuse that lineage when every traced base partition column already matches the storeddate_truncunit (handlingPARTITION BY (trx_date)queries includingWEEK/QUARTER, unit-firstdate_trunc(unit, col), and disabledMERGE_DATE_TRUNC). Otherwise fall back togetRelatedTableInfos(partitionCol, timeUnit, ...)to handle bare-column or coarser-rollupPARTITION BY (date_trunc(trx_date, unit))declarations.- Keep all existing partition lineage and compatibility checks in
PartitionIncrementCheckerandMTMVPlanUtil.checkMTMVPartitionInfoLike().MTMVPlanUtil.analyzeQueryWithSql()andensureMTMVQueryUsable()onmaster.SELF_MANAGE,FOLLOW_BASE_TABLE, andCREATE MATERIALIZED VIEWpaths remain unchanged.Testing
MTMVPartitionReanalysisTest: 18 tests passed (covering single-table andUNION ALLaliases with both implicit and explicitdate_truncpartition declarations, bare-column explicit rollup, finer-to-coarser explicit rollup,JOINqueries,WEEK/QUARTERunits, reversedDATE_TRUNCargument order withMERGE_DATE_TRUNCdisabled, quoted/dotted aliases, and rejection of incompatible source or unit changes).MTMVPlanUtilTest: 25 tests passed.mvn -f fe/pom.xml -pl fe-core -am validate -DskipTests): passed.Release note
Fix refresh failures for asynchronous materialized views with aliased date partition outputs after compatible base-table schema changes.
Check List (For Author)