Skip to content

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

Closed

Description

@Ariznawlll

Describe the bug

DATA BRANCH DIFF treats a one-sided column rename as schema-equivalent and can correctly compare the two tables, but DATA BRANCH MERGE and DATA BRANCH PICK cannot apply the same change set.

The apply stage builds its SQL with the source-side column names. If the source column was renamed, the destination rejects the new name; if only the destination was renamed, the destination rejects the old name. The behavior is symmetric and affects both MERGE and PICK.

Tested at commit 2eb7f523e5a10f352d3e258183ed8440510388de.

Steps to reproduce

drop database if exists g4d_rename_apply;
create database g4d_rename_apply;
use g4d_rename_apply;

create table base(id int primary key, payload int);
insert into base values (1,10),(2,20);
data branch create table src from base;
alter table src rename column payload to payload_new;
update src set payload_new=11 where id=1;
insert into src values (3,30);

data branch diff src against base;
data branch merge src into base;
select * from base order by id;

The same result occurs with:

data branch pick src into base keys(1,3) when conflict accept;

It also occurs in the reverse direction when the destination column is renamed and the source retains the original name.

Actual behavior

With the source renamed:

ERROR 20301 (HY000): invalid input: column payload_new does not exist

With the destination renamed:

ERROR 20301 (HY000): invalid input: column payload does not exist

The destination rows remain unchanged.

Expected behavior

MERGE and PICK should map columns by the same stable column identity used by schema-equivalence and DIFF, so a one-sided rename can be applied to the destination column name.

Reproducibility

Reproduced in 3/3 runs for all four combinations:

  • MERGE with source renamed
  • MERGE with destination renamed
  • PICK with source renamed
  • PICK with destination renamed

Code context

isSchemaEquivalent intentionally allows different column names when column IDs and logical types match. The apply path later derives visible column names from the source table definition, and those names are used when writing to the destination table.

Activity

  1. added this to the MO-202607 milestone on Jul 23, 2026
  2. added
    kind/bug
    on Jul 23, 2026
  3. added theissue type on Jul 23, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Aug 2, 2026
  5. added a commit that references this issue on Aug 3, 2026
    5951727
  6. gouhongshen commented on Aug 3, 2026

    @gouhongshen
    Contributor

    fixed

  7. added and removed
    severity/s0
    on Aug 3, 2026
  8. Ariznawlll commented on Aug 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:c58cd292d3e6e039a8882654d3b20ad345171e87
    • 部署方式:macOS arm64,本地 MatrixOne 单 CN 黑盒环境
    • 测试日期:2026-08-04

    原问题验证

    在 branch 创建后对等价逻辑列执行 rename,再重跑 PICK 和 MERGE。apply 使用逻辑列身份完成映射,不再因为端点列名不同而失败;连续执行 3 轮通过。

    Happy Path 覆盖

    1. source 侧 rename 后,以复合主键执行 PICK,选中行正确应用。
    2. destination 侧 rename 后执行 MERGE,INSERT/UPDATE/DELETE 均正确应用。
    3. apply 后比较完整数据集,rename 列、未选择行及复合主键均符合预期。

    Unhappy Path 覆盖

    1. 构造 source/target 同行冲突并使用 WHEN CONFLICT FAIL,语句返回冲突。
    2. 失败后重新读取目标表,所有行保持原值,没有部分更新。
    3. 连续 3 轮未观察到列错位、重复行、panic 或 hang。

    白盒验证

    定向覆盖历史 LCA probe 列布局、source-to-target index 映射、destination column name 和 renamed PK compatibility;相关测试连续执行 3 轮通过。

    回归测试

    测试证据

    测试结论

    测试通过。

  9. added 3 commits that reference this issue on Sep 17, 2026
    9d04392
    f86aacb
    6d534bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions