Repository navigation
fix(data branch): apply changes after column renames - #26588
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed head 660f35c. The destination/LCA column-name mapping now follows the lineage-resolved target-index ownership through online/portable apply, SQL LCA probing, reader fallback, historical projection, and normal/composite/fake-PK paths. I checked rename symmetry, PK renames, source-only columns, generated-column write exclusion, and bounded multi-generation hydration; no blocking correctness or lifecycle issue found. Local focused regressions and the full pkg/frontend test suite pass.
) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26062 ## What this PR does / why we need it: ### Root cause DATA BRANCH schema reconciliation already identifies equivalent columns by stable lineage, but the apply paths emitted destination SQL with source-side column names. A one-sided rename therefore passed DIFF and later failed during MERGE or PICK. The primary-key and LCA time-travel paths also used current logical names where stable endpoint or historical LCA names were required, so destination-side and primary-key renames could fail before or during apply. Historical PICK hydration also needs to distinguish the base endpoint from an older physical generation of the target. Treating every non-current-target table ID as the base endpoint applies destination names to an old target schema; a bounded PICK across multiple ALTER generations then tries to resolve columns that did not exist at the upper bound. ### Changes - carry the lineage-resolved destination column names through every MERGE/PICK write path, including batch/direct deletes, full-row predicates, composite primary keys, and tables without explicit primary keys; - validate primary-key compatibility through the same stable column identity used for schema reconciliation, while continuing to reject primary-key membership or kind changes; - resolve time-travel probes with the validated historical LCA column names and preserve renamed primary-key identity across historical generations; - classify historical hydration relations by stable table ID, applying base endpoint names only to the actual base relation and retaining historical target-generation names for bounded PICK; - add focused unit coverage and BVT coverage for source-side and destination-side renames across MERGE/PICK, normal/composite/fake primary keys, bounded multi-generation PICK, and schema evolution with source-only columns. Generated columns remain visible for comparison but are still excluded from destination writes. ### Validation - proved the original failure in both rename directions: source-side apply failed on the new name; destination-side apply failed schema compatibility on the renamed destination column; destination rows remained unchanged; - `make build`; - `go vet -mod=readonly ./pkg/frontend` with the repository CGo include/link settings; - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend`; - `golangci-lint v2.6.2` built with Go 1.26.4 against `./pkg/frontend/...`: 0 issues; - focused DATA BRANCH unit tests for lineage mapping, apply SQL, historical LCA names, historical hydration endpoint classification, generated columns, and primary-key compatibility; - `mo-tester` BVT: `branch_rename_apply` 105/105 assertions passed; - existing bounded multi-generation PICK BVT `git4data/branch/pick/pick_9.sql`: 173/173 assertions passed with the same metadata-ignore mode used by CI; - broader related BVT set (`branch_rename_apply`, `branch_rename_output`, `merge_generated_column`, `merge_schema_evolve`): 337/337 assertions passed, with no failed, ignored, or abnormal cases; - manually inspected the generated BVT result against the intended row and destination-column semantics. ### CI follow-up - the initial SCA failure was caused by an unused compatibility wrapper introduced by this PR; the wrapper was removed and the matching linter gate now passes locally; - the initial PROXY BVT failure was caused by this PR misclassifying a historical target generation as the base endpoint; the stable-ID classification fix restores the existing `pick_9.sql` expectations; - the Coverage failure was downstream of the failed PROXY coverage producer, not a separate root cause. There are no unrelated CI blockers to track or rerun. ### Residual risks No known residual risk. The behavior change is limited to mappings whose stable lineage and logical schema are already validated; drop/add replacements, type changes, generated-column definition changes, and primary-key drift continue to fail closed. There are no API, catalog, storage-format, concurrency, or resource-lifecycle changes. --------- Co-authored-by: XuPeng-SH <[email protected]>
) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26062 ## What this PR does / why we need it: ### Root cause DATA BRANCH schema reconciliation already identifies equivalent columns by stable lineage, but the apply paths emitted destination SQL with source-side column names. A one-sided rename therefore passed DIFF and later failed during MERGE or PICK. The primary-key and LCA time-travel paths also used current logical names where stable endpoint or historical LCA names were required, so destination-side and primary-key renames could fail before or during apply. Historical PICK hydration also needs to distinguish the base endpoint from an older physical generation of the target. Treating every non-current-target table ID as the base endpoint applies destination names to an old target schema; a bounded PICK across multiple ALTER generations then tries to resolve columns that did not exist at the upper bound. ### Changes - carry the lineage-resolved destination column names through every MERGE/PICK write path, including batch/direct deletes, full-row predicates, composite primary keys, and tables without explicit primary keys; - validate primary-key compatibility through the same stable column identity used for schema reconciliation, while continuing to reject primary-key membership or kind changes; - resolve time-travel probes with the validated historical LCA column names and preserve renamed primary-key identity across historical generations; - classify historical hydration relations by stable table ID, applying base endpoint names only to the actual base relation and retaining historical target-generation names for bounded PICK; - add focused unit coverage and BVT coverage for source-side and destination-side renames across MERGE/PICK, normal/composite/fake primary keys, bounded multi-generation PICK, and schema evolution with source-only columns. Generated columns remain visible for comparison but are still excluded from destination writes. ### Validation - proved the original failure in both rename directions: source-side apply failed on the new name; destination-side apply failed schema compatibility on the renamed destination column; destination rows remained unchanged; - `make build`; - `go vet -mod=readonly ./pkg/frontend` with the repository CGo include/link settings; - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend`; - `golangci-lint v2.6.2` built with Go 1.26.4 against `./pkg/frontend/...`: 0 issues; - focused DATA BRANCH unit tests for lineage mapping, apply SQL, historical LCA names, historical hydration endpoint classification, generated columns, and primary-key compatibility; - `mo-tester` BVT: `branch_rename_apply` 105/105 assertions passed; - existing bounded multi-generation PICK BVT `git4data/branch/pick/pick_9.sql`: 173/173 assertions passed with the same metadata-ignore mode used by CI; - broader related BVT set (`branch_rename_apply`, `branch_rename_output`, `merge_generated_column`, `merge_schema_evolve`): 337/337 assertions passed, with no failed, ignored, or abnormal cases; - manually inspected the generated BVT result against the intended row and destination-column semantics. ### CI follow-up - the initial SCA failure was caused by an unused compatibility wrapper introduced by this PR; the wrapper was removed and the matching linter gate now passes locally; - the initial PROXY BVT failure was caused by this PR misclassifying a historical target generation as the base endpoint; the stable-ID classification fix restores the existing `pick_9.sql` expectations; - the Coverage failure was downstream of the failed PROXY coverage producer, not a separate root cause. There are no unrelated CI blockers to track or rerun. ### Residual risks No known residual risk. The behavior change is limited to mappings whose stable lineage and logical schema are already validated; drop/add replacements, type changes, generated-column definition changes, and primary-key drift continue to fail closed. There are no API, catalog, storage-format, concurrency, or resource-lifecycle changes. --------- Co-authored-by: XuPeng-SH <[email protected]>
) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26062 ## What this PR does / why we need it: ### Root cause DATA BRANCH schema reconciliation already identifies equivalent columns by stable lineage, but the apply paths emitted destination SQL with source-side column names. A one-sided rename therefore passed DIFF and later failed during MERGE or PICK. The primary-key and LCA time-travel paths also used current logical names where stable endpoint or historical LCA names were required, so destination-side and primary-key renames could fail before or during apply. Historical PICK hydration also needs to distinguish the base endpoint from an older physical generation of the target. Treating every non-current-target table ID as the base endpoint applies destination names to an old target schema; a bounded PICK across multiple ALTER generations then tries to resolve columns that did not exist at the upper bound. ### Changes - carry the lineage-resolved destination column names through every MERGE/PICK write path, including batch/direct deletes, full-row predicates, composite primary keys, and tables without explicit primary keys; - validate primary-key compatibility through the same stable column identity used for schema reconciliation, while continuing to reject primary-key membership or kind changes; - resolve time-travel probes with the validated historical LCA column names and preserve renamed primary-key identity across historical generations; - classify historical hydration relations by stable table ID, applying base endpoint names only to the actual base relation and retaining historical target-generation names for bounded PICK; - add focused unit coverage and BVT coverage for source-side and destination-side renames across MERGE/PICK, normal/composite/fake primary keys, bounded multi-generation PICK, and schema evolution with source-only columns. Generated columns remain visible for comparison but are still excluded from destination writes. ### Validation - proved the original failure in both rename directions: source-side apply failed on the new name; destination-side apply failed schema compatibility on the renamed destination column; destination rows remained unchanged; - `make build`; - `go vet -mod=readonly ./pkg/frontend` with the repository CGo include/link settings; - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend`; - `golangci-lint v2.6.2` built with Go 1.26.4 against `./pkg/frontend/...`: 0 issues; - focused DATA BRANCH unit tests for lineage mapping, apply SQL, historical LCA names, historical hydration endpoint classification, generated columns, and primary-key compatibility; - `mo-tester` BVT: `branch_rename_apply` 105/105 assertions passed; - existing bounded multi-generation PICK BVT `git4data/branch/pick/pick_9.sql`: 173/173 assertions passed with the same metadata-ignore mode used by CI; - broader related BVT set (`branch_rename_apply`, `branch_rename_output`, `merge_generated_column`, `merge_schema_evolve`): 337/337 assertions passed, with no failed, ignored, or abnormal cases; - manually inspected the generated BVT result against the intended row and destination-column semantics. ### CI follow-up - the initial SCA failure was caused by an unused compatibility wrapper introduced by this PR; the wrapper was removed and the matching linter gate now passes locally; - the initial PROXY BVT failure was caused by this PR misclassifying a historical target generation as the base endpoint; the stable-ID classification fix restores the existing `pick_9.sql` expectations; - the Coverage failure was downstream of the failed PROXY coverage producer, not a separate root cause. There are no unrelated CI blockers to track or rerun. ### Residual risks No known residual risk. The behavior change is limited to mappings whose stable lineage and logical schema are already validated; drop/add replacements, type changes, generated-column definition changes, and primary-key drift continue to fail closed. There are no API, catalog, storage-format, concurrency, or resource-lifecycle changes. --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26062
What this PR does / why we need it:
Root cause
DATA BRANCH schema reconciliation already identifies equivalent columns by stable lineage, but the apply paths emitted destination SQL with source-side column names. A one-sided rename therefore passed DIFF and later failed during MERGE or PICK. The primary-key and LCA time-travel paths also used current logical names where stable endpoint or historical LCA names were required, so destination-side and primary-key renames could fail before or during apply.
Historical PICK hydration also needs to distinguish the base endpoint from an older physical generation of the target. Treating every non-current-target table ID as the base endpoint applies destination names to an old target schema; a bounded PICK across multiple ALTER generations then tries to resolve columns that did not exist at the upper bound.
Changes
Generated columns remain visible for comparison but are still excluded from destination writes.
Validation
make build;go vet -mod=readonly ./pkg/frontendwith the repository CGo include/link settings;.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend;golangci-lint v2.6.2built with Go 1.26.4 against./pkg/frontend/...: 0 issues;mo-testerBVT:branch_rename_apply105/105 assertions passed;git4data/branch/pick/pick_9.sql: 173/173 assertions passed with the same metadata-ignore mode used by CI;branch_rename_apply,branch_rename_output,merge_generated_column,merge_schema_evolve): 337/337 assertions passed, with no failed, ignored, or abnormal cases;CI follow-up
pick_9.sqlexpectations;Residual risks
No known residual risk. The behavior change is limited to mappings whose stable lineage and logical schema are already validated; drop/add replacements, type changes, generated-column definition changes, and primary-key drift continue to fail closed. There are no API, catalog, storage-format, concurrency, or resource-lifecycle changes.