Skip to content

fix(data branch): apply changes after column renames - #26588

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26062
Aug 3, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26062

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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

  • 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.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@XuPeng-SH
XuPeng-SH merged commit 5951727 into matrixorigin:main Aug 3, 2026
25 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DATA BRANCH MERGE and PICK cannot apply changes after an equivalent column rename

3 participants