Repository navigation
Closed
Labels
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
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:
- 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, orOUTPUT ASlooking up columns by physical ID/name instead of lineage-mapped base columns). runLCAProbeWithReaderFallbackskips row reordering (sels) when all rows hit (len(missedRows) == 0), even though reader scans can return rows out of order.- Materializing
TIMESTAMPcolumns via SQL string formatting fails in negative fixed offsets nearyear 9999(overflowing UTC year9999), fails around1970-01-01minimum storable non-zero timestamps under positive offsets, or loses distinction on DST fall-back fold instants (e.g.,America/New_York). DECIMALattribute differences (e.g.DECIMAL(9,2) UNSIGNEDvsDECIMAL(9,2)) pass compatibility checks despite mismatchingNumericAttributes.- Unicode case-fold equivalent names (e.g.
s/ long-sſU+017For__mo_diff_ſource) cause silent overwrite/collision betweenstrings.ToLowermaps andEqualFoldKeyDDL validation (build_ddl.go).
Expected Behavior
DATA BRANCH DIFF ... OUTPUT ASmaterializes the output table using lineage-mapped columns and target visible ordering without hiddenRow_IDor target-only base-history leaks, preservesselsrow order in LCA probe fallback, checksNumericAttributescompatibility, handles DST fold / min-maxTIMESTAMPformatting accurately, and handlesEqualFoldKeycolumn 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
fix(data branch): use lineage mapping for diff output tables (#32971)
XuPeng-SH commentedon Nov 21, 2026
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 head691c13dec0与合并提交抽核的三个生产文件及新增 SQL case 的 blob 一致;旧独立评审版本的两个生产文件 blob 不同,故不把旧证据等同合并版本覆盖。本轮只核远端,未重跑、未验收通过。请用合并后的 main 构建走真实 SQL,验输出表列顺序/值及无多余历史槽,核全命中 fallback、时间边界/两种 DST 实际时刻、属性/Unicode 冲突和失败后无残留表。非 target-only 的历史 COPY ALTER 槽碰撞,以及 CTAS 绕过列名校验是已披露的相邻既有路径,不算本次修复或验收。保持工单开放,待 QA 记录。
Ariznawlll commentedon Nov 22, 2026
结论
测试通过。
DATA BRANCH DIFF ... OUTPUT AS在本 Issue 所列的 schema 演进、时间和列名冲突场景已验证,并补充 main MOTR 回归。关键证据
main@cc2c82dc4a6cb2cbcc046ef9caebde50c6004b15,独立 macOS arm64 standalone MO;运行时git_version()为短 SHAcc2c82dc4,包含 fix(data branch): use lineage mapping for diff output tables #32971。__mo_diff_source_1,业务列保留正确值。增补即时重命名场景,目标及基表更新分别输出target、base。America/New_YorkDST 回拨的两个实际时刻输出为 UTC05:30与06:30;负时区 year-9999 和跨时区最小时间边界正常物化。DECIMAL UNSIGNED 属性不匹配 3/3 拒绝,且无遗留输出表。-count=3通过。回归 MOTR #374 最终用例 replay 3/3、195/195 语句通过;较早用例版本的完整12_git4datasuite 为 87 通过、0 失败、1 跳过,最终新增 rename 和时间下界后已单独重放 3 轮。PR 离线 CI 4 项通过。待解决点
本 Issue 修复范围内无已知待解决项。测试为独立单节点;历史 COPY ALTER 非 target-only 槽碰撞和 CTAS 绕过列名校验是已披露的相邻既有问题,不在本次验收范围内。