Skip to content

[Bug]: DATA BRANCH DIFF OUTPUT AS fails or corrupts results on altered/renamed columns and timestamp/Unicode edge cases #32969

Closed

Description

@VioletQwQ-0

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

d2e7103

Other Environment Information

- Hardware parameters: Apple Silicon (darwin/arm64)
- OS type: macOS (reproducible in standalone local mo-service / BVT)
- Others: DATA BRANCH DIFF ... OUTPUT AS

Actual Behavior

DATA BRANCH DIFF ... OUTPUT AS <out_table> fails or corrupts results when branches undergo schema evolution (ADD COLUMN, in-place RENAME COLUMN, COPY ALTER reordering/dropping columns), special column types/attributes, or Unicode case-fold equivalent names:

  1. Output table DDL and row materialization mis-map altered/renamed columns when target column indexes/names diverge from base physical layout (including hidden catalog.Row_ID, base-side historical batches still including target-only columns, or OUTPUT AS looking up columns by physical ID/name instead of lineage-mapped base columns).
  2. runLCAProbeWithReaderFallback skips row reordering (sels) when all rows hit (len(missedRows) == 0), even though reader scans can return rows out of order.
  3. Materializing TIMESTAMP columns via SQL string formatting fails in negative fixed offsets near year 9999 (overflowing UTC year 9999), fails around 1970-01-01 minimum storable non-zero timestamps under positive offsets, or loses distinction on DST fall-back fold instants (e.g., America/New_York).
  4. DECIMAL attribute differences (e.g. DECIMAL(9,2) UNSIGNED vs DECIMAL(9,2)) pass compatibility checks despite mismatching NumericAttributes.
  5. Unicode case-fold equivalent names (e.g. s / long-s ſ U+017F or __mo_diff_ſource) cause silent overwrite/collision between strings.ToLower maps and EqualFoldKey DDL validation (build_ddl.go).

Expected Behavior

  • DATA BRANCH DIFF ... OUTPUT AS materializes the output table using lineage-mapped columns and target visible ordering without hidden Row_ID or target-only base-history leaks, preserves sels row order in LCA probe fallback, checks NumericAttributes compatibility, handles DST fold / min-max TIMESTAMP formatting accurately, and handles EqualFoldKey column name collisions consistently without silent mis-selection.

Steps to Reproduce

drop database if exists test_diff_output_as_altered;
create database test_diff_output_as_altered;
use test_diff_output_as_altered;

-- 1. COPY ALTER with ADD FIRST reassigns physical column identities
create table copy_base(id int primary key, amount decimal(9,2) not null);
insert into copy_base values (1,10.50),(2,20.00);
data branch create table copy_tar from copy_base;
alter table copy_tar algorithm=copy, add column extra int not null default 9 first;
update copy_tar set amount = 11.75 where id = 1;
update copy_base set amount = 21.25 where id = 2;
data branch diff copy_tar against copy_base columns (amount,extra) output as copy_diff;

-- 2. Base-side COPY ALTER DROP COLUMN with historical pre-alter rows
create table drop_base(id int primary key, x int, y int, amount decimal(9,2) not null);
insert into drop_base values (10,11,22,10.00);
data branch create table drop_tar from drop_base;
insert into drop_base values (20,77,88,20.00);
update drop_base set amount = 15.25 where id = 10;
alter table drop_base algorithm=copy, drop column x, drop column y;
data branch diff drop_tar against drop_base output as drop_diff;

-- 3. DST fall-back fold & year-9999 TIMESTAMP in negative offset
set time_zone = '-05:00';
create table timestamp_max_base(id int primary key, ts timestamp(6));
data branch create table timestamp_max_tar from timestamp_max_base;
insert into timestamp_max_tar values (1,'2024-11-03 01:30:00.123456'),(2,'9999-12-31 23:59:59.999999');
alter table timestamp_max_tar algorithm=copy, add column extra int not null default 9 first;
data branch diff timestamp_max_tar against timestamp_max_base output as timestamp_max_diff;

-- 4. Metadata column collision with Unicode fold equivalent name
create table fold_base(id int primary key, `__mo_diff_ſource` int);
insert into fold_base values (1, 10);
data branch create table fold_tar from fold_base;
alter table fold_tar algorithm=copy, add column extra int not null default 9 first;
update fold_tar set `__mo_diff_ſource` = 20 where id = 1;
data branch diff fold_tar against fold_base output as fold_diff;

Additional information

Observed while running DATA BRANCH DIFF ... OUTPUT AS across schema evolution (ADD / RENAME / COPY ALTER), temporal edge cases (TIMESTAMP DST fold & boundary instants), DECIMAL UNSIGNED, and Unicode fold collisions.

Activity

  1. added
    kind/bug
    on Nov 20, 2026
  2. XuPeng-SH commented on Nov 21, 2026

    @XuPeng-SH
    Contributor

    QA 转测:#32971 已合入 main,合并提交 a9dda368fd9b0ab0c5c243f49b7ffc67a8bd61c8。范围为本 issue 的 DATA BRANCH DIFF ... OUTPUT AS 列 lineage/输出顺序、LCA 全命中时的行顺序、TIMESTAMP 边界及 DST、DECIMAL 属性和 Unicode 名称冲突。

    版本及证据:作者在 6f357bbcdb9 报告 404 项聚焦单测及 BVT;独立评审在 dc1dc9e637 记录 404 项聚焦通过和真实双 CN MySQL 协议验证(COPY ALTER、DST 回拨两个时刻、时间边界、会话时区及不兼容 DECIMAL 拒绝)。队列记录本 PR 通过 CI Required。最终 PR head 691c13dec0 与合并提交抽核的三个生产文件及新增 SQL case 的 blob 一致;旧独立评审版本的两个生产文件 blob 不同,故不把旧证据等同合并版本覆盖。本轮只核远端,未重跑、未验收通过。

    请用合并后的 main 构建走真实 SQL,验输出表列顺序/值及无多余历史槽,核全命中 fallback、时间边界/两种 DST 实际时刻、属性/Unicode 冲突和失败后无残留表。非 target-only 的历史 COPY ALTER 槽碰撞,以及 CTAS 绕过列名校验是已披露的相邻既有路径,不算本次修复或验收。保持工单开放,待 QA 记录。

  3. Ariznawlll commented on Nov 22, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。DATA BRANCH DIFF ... OUTPUT AS 在本 Issue 所列的 schema 演进、时间和列名冲突场景已验证,并补充 main MOTR 回归。

    关键证据

    • 2026-11-23 官方 main@cc2c82dc4a6cb2cbcc046ef9caebde50c6004b15,独立 macOS arm64 standalone MO;运行时 git_version() 为短 SHA cc2c82dc4,包含 fix(data branch): use lineage mapping for diff output tables #32971。
    • COPY ALTER 增列、基表删列和 Unicode 列名冲突各重复 3 次,核对输出列顺序与行值;冲突场景元数据列自动改名 __mo_diff_source_1,业务列保留正确值。增补即时重命名场景,目标及基表更新分别输出 target、base。
    • America/New_York DST 回拨的两个实际时刻输出为 UTC 05:30 与 06:30;负时区 year-9999 和跨时区最小时间边界正常物化。DECIMAL UNSIGNED 属性不匹配 3/3 拒绝,且无遗留输出表。
    • LCA reader 全命中保序与类型属性检查的两个定向 Go 测试均 -count=3 通过。回归 MOTR #374 最终用例 replay 3/3、195/195 语句通过;较早用例版本的完整 12_git4data suite 为 87 通过、0 失败、1 跳过,最终新增 rename 和时间下界后已单独重放 3 轮。PR 离线 CI 4 项通过。

    待解决点

    本 Issue 修复范围内无已知待解决项。测试为独立单节点;历史 COPY ALTER 非 target-only 槽碰撞和 CTAS 绕过列名校验是已披露的相邻既有问题,不在本次验收范围内。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triagephase/testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions