[improvement](ivm) Stabilize IVM layout signature via unique-key lineage and add ivm_plan_signature() #71241
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #71241"
general
weight: 0.35
morrySnow
Background
Incremental View Maintenance (IVM) materialized views store a persisted layout signature (
IvmPlanSignature) so that after an upgrade, an incremental refresh can detect when the physical unique-key or column layout produced by the normalized IVM plan no longer matches existing MV data and safely fall back to a complete refresh. Previously,IvmPlanSignatureGeneratorserialized the entire normalized logical plan tree belowLogicalOlapTableSink, and users could only inspect the persisted SHA-256 digest rather than the underlying canonical signature text.What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Enhancement
Problem Summary:
Serializing the full normalized logical plan makes the IVM layout signature overly sensitive to harmless planner refactors (adding/merging
LogicalProject,Filter,SubQueryAlias, join reordering belowAggregate, or alias renames), causing unnecessary full refreshes after upgrades. This PR replaces full-plan serialization with a layout-focused canonical signature that pins the target sink schema and traces every Merge-on-WriteUNIQUE KEYcolumn back to its base scan columns, and adds an FE-only scalar functionivm_plan_signature('[catalog.][db.]mv')so users and tests can inspect the live canonical signature text directly. Existing IVM MVs that were created with the previous signature format will fall back to a one-time complete refresh on their next refresh and persist the new signature.Details
.out).-
IvmPlanSignatureGenerator.java/IvmPlanSignature.java(~1,034 lines): scoped demand-driven lineage tracing for all targetUNIQUE KEYcolumns, sink schema + extra-output pinning, live-probedROW_ID_HASH_DEF, structural CSE (SHARED), and explicit expression serialization.-
IvmPlanSignatureEvaluator.java/IvmPlanSignatureFunc.java/BuiltinScalarFunctions.java/ScalarFunctionVisitor.java/FoldConstantRuleOnFE.java(~300 lines): FE-only constant-foldedivm_plan_signature('[catalog.][db.]mv')scalar function.-
IvmPlanSignatureGeneratorTest.java/IvmPlanSignatureFuncTest.java/IvmNormalizeUniqKeysMTMVTest.java/test_ivm_plan_signature_function.{groovy,out}(~1,014 lines): unit and regression test coverage.- Before:
IvmPlanSignatureGeneratorserialized the whole logical plan tree, so intermediate projections, filters, subquery aliases, join order changes underAggregate, and alias renames changed the signature. Only the SHA-256 hash was stored, with no SQL way to inspect the raw canonical signature text.- After: The signature encodes only what determines physical MV layout compatibility:
TABLE_SINKordered column names/types,EXTRA_OUTPUTS(if sink output exceeds target slots), live-probedROW_ID_HASH_DEF(whenRowIdHashis used, probed with both numeric and string placeholders),SHAREDstructural CSE definitions (when a non-leaf expression is referenced at least twice), andUNIQUE_KEYSlineage for every target-table key column (__DORIS_IVM_ROW_ID_COL__, visible keys, andivm_use_full_keyshidden keys).ivm_plan_signature('[catalog.][db.]mv')computes and returns the live canonical signature string on FE without running a refresh, mutating metadata, or consuming stream offsets (returningNULLfor append-only duplicate-key IVM MVs, and requiringSHOWprivilege).PLAN_SIGNATURE_MISMATCHfallback to complete refresh upon upgrade, after which the new stable signature is persisted. No user configuration changes are required.Testing
-
IvmPlanSignatureGeneratorTest(17 tests): stability across intermediateProject/Filter/SubQueryAlias, join reordering belowAggregate, nestedUNION ALLunderAggregate, lambda parameter alpha-renaming, partition-id changes; sensitivity to join type/order,UNION ALLbranch order,ivm_use_full_keys, sink truncation/casts,LogicalRepeatgrouping sets,TABLE_SINK/EXTRA_OUTPUTS,CastvsTryCast; scalability on 30-table join and 25-level doubling DAG via structural CSE; self-referencingExprIdcycle safety.-
IvmPlanSignatureFuncTest(6 tests): 1/2/3-part qualified name parsing with optional backticks, malformed name and non-internal catalog rejection, non-constant argument rejection,NULLpropagation, FE constant folding to canonical text orNULL.-
IvmNormalizeUniqKeysMTMVTest(64 tests): all existing IVM unique-key normalization tests pass.mvn -f fe/pom.xml -pl fe-core -am validate -DskipTestspassed with 0 violations.-
mtmv_p0/ivm:test_ivm_plan_signature_function(golden.outverifies live canonical signature strings for single-table, multi-table inner/left join,UNION ALL, aggregate,ivm_use_full_keys, append-only duplicate-key MV, qualified/backtick names, and error cases),test_ivm_plan_signature_fallback,test_ivm_partition_signature_fallback,test_ivm_sink_truncation_signature— 4/4 suites passed.Release note
Stabilized IVM layout signature generation to depend only on target sink schema and unique-key column lineage, and added the
ivm_plan_signature('[catalog.][db.]mv')scalar function to inspect the live canonical layout signature text of an IVM materialized view.Check List (For Author)