Repository navigation
Open
Description
Consolidated tracking scope: CTAS inferred target type and persisted value consistency
Original reproductions and discussions remain available in the source issues below. Administrative consolidation is not a claim that a defect is fixed. Each input family and execution path retains independent acceptance.
Included reports
- #28127 — [Bug]: CTAS persists fractional TIME values in an unscaled TIME column
- #30942 — [Bug]: decimal literal 0.1 infers DECIMAL(1,1) (no integer digit) — CTAS column rejects values >= 1
Acceptance checklist
- For the fractional TIME reproduction, the persisted CTAS value and its declared fractional-second precision must agree; compare direct INSERT SELECT into TIME/TIME(0) and explicitly scaled TIME targets.
- Retain the pure-fraction decimal-literal case: infer the MySQL-compatible precision/scale for 0.1 (DECIMAL(2,1) in the report), verify SHOW CREATE/column metadata, and test a subsequent representable 1.5 insert.
- Preserve valid 1.5/1.50 and explicit DECIMAL controls, NULL behavior, and every existing CTAS tracker row as separate acceptance cases. These reports do not establish one immediate implementation root cause.
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- MO version: 8.0.30-MatrixOne-v
- MySQL version: 8.0.45
- Verify date: 2026-05-18Actual Behavior
After re-verifying #14792, several CREATE TABLE ... AS SELECT schema behaviors are still inconsistent with MySQL.
Already verified fixed:
- scene 5
- scene 7
Known MO-specific behavior not split into this tracker:
TEXT/BLOB DEFAULT NULLprinting difference inshow create table
Still inconsistent with MySQL:
- aggregate functions in CTAS:
avg/sum/count/max/min - bitwise aggregate functions in CTAS:
bit_and/bit_or/bit_xor - plain
DECIMALcolumn definition after CTAS concat_wsresult column definition after CTASdate_formatresult column definition after CTASAUTO_INCREMENTattribute is retained after CTAS
Expected Behavior
The CTAS target schema should be consistent with MySQL for the remaining scenarios above.
Steps to Reproduce
1. aggregate functions in CTAS
drop table if exists agg01;
drop table if exists math01;
create table math01 (col1 int default 0, col2 decimal, col3 float, col4 double not null);
insert into math01 values (1, 7382.4324, 432453.3243, -2930.321323);
insert into math01 values (-100, 3283.32324, 328932.0, -9392032);
insert into math01 values (22813, -241, 932342.4324, -0.1);
insert into math01 values (null, null, null, 10);
create table agg01 as
select avg(col1) as avgCol, sum(col2) as sumcol, count(col3) as countCol, max(col4) as maxCol, min(col4) as minCol
from math01;
show create table agg01;
desc agg01;
2. bitwise aggregate functions in CTAS
drop table if exists bit02;
drop table if exists bit01;
create table bit01 (col1 char(1), col2 int);
insert into bit01 values ('a',111),('a',110),('a',100),('a',000),('b',001),('b',011);
create table bit02 as
select bit_and(col2), bit_or(col2), bit_xor(col2)
from bit01;
show create table bit02;
desc bit02;
3. plain DECIMAL column after CTAS
drop table if exists dst01;
drop table if exists src01;
create table src01 (col7 decimal);
insert into src01 values (3232.000), (0.0001), (null);
create table dst01 as select * from src01;
show create table dst01;
desc dst01;
4. concat_ws result column after CTAS
drop table if exists string02;
drop table if exists string01;
create table string01 (col1 varchar(40), col2 char, col3 text default null);
insert into string01 values (' database system', 'a', 'x');
insert into string01 values (' string function ', '1', 'y');
insert into string01 values ('test create table as select', '0', null);
create table string02 as
select concat_ws(',', col1, 'abcde') as newCol
from string01;
show create table string02;
desc string02;
5. date_format result column after CTAS
drop table if exists time02;
drop table if exists time01;
create table time01(col1 date, col2 datetime, col3 timestamp, col4 time);
insert into time01 values ('2020-10-11', '2023-11-11 10:00:01', '1997-01-13 12:12:12.000', '12:12:12');
insert into time01 values ('1919-12-01', '1990-10-10 01:01:01', '2001-12-12 01:01:01.000', '10:59:59');
insert into time01 values (null, null, null, null);
create table time02 as
select date_format(col2, '%W %M %Y') from time01;
show create table time02;
desc time02;
6. AUTO_INCREMENT attribute retained after CTAS
drop table if exists table02;
drop table if exists table01;
create table table01 (
id int auto_increment primary key,
col1 varchar(255) not null
);
insert into table01 (col1) values ('Value2'), ('Value3');
create table table02 as select * from table01;
show create table table02;
desc table02;Additional information
This issue is a tracker that summarizes the remaining incompatible CTAS schema behaviors from #14792.
Activity
Ariznawlll commentedon Jul 2, 2026
Additional Model 11 metadata coverage on latest main
51656deb6still reproduces CTAS/view schema inference gaps against MySQL 8.0.45.Repro:
Observed differences:
id int NOT NULL DEFAULT '0'; MO: keepsid int NOT NULL AUTO_INCREMENT.dec_expr decimal(9,3); MO:DECIMAL(38,3).concat_expr varchar(14)andif_mixed varchar(3); MO:VARCHAR(65535)for both.dt_expr datetime NULL DEFAULT NULL; MO:DATETIME(0) NOT NULL.information_schema.columnsalso exposes__mo_fake_pk_colfor the CTAS table.This is the same family as the existing CTAS schema tracker, adding mixed arithmetic/string/datetime expression coverage.
Ariznawlll commentedon Jul 2, 2026
Additional Model 11 CTAS metadata coverage on latest main
51656deb6:Observed MySQL vs MO schema differences:
count(i): MySQLbigint NOT NULL DEFAULT 0; MOBIGINT NOT NULL DEFAULT NULL.sum(decimal(8,2)): MySQLdecimal(30,2); MODECIMAL(38,2).avg(int): MySQLdecimal(14,4); MODOUBLE.row_number(): MySQLbigint unsigned; MOBIGINT.sum(int): MySQLdecimal(32,0); MOBIGINT.x: MySQLdecimal(2,1); MODECIMAL(20,1).y: MySQLvarchar(20) NULL; MOVARCHAR(65535) NOT NULL.A separate value-materialization bug was filed for CTAS +
GROUP_CONCATwith NULL values: #25389.Ariznawlll commentedon Jul 3, 2026
Additional CTAS/derived UNION coverage on latest main
49842fb04shows the schema inference gap can become a materialization failure when later UNION branches contain NULL.Repro:
MySQL 8.0.45 succeeds and creates nullable columns:
MatrixOne latest main
49842fb04fails during CTAS materialization:This appears to be the same CTAS UNION schema-inference family already tracked here, but with a value-path failure instead of only metadata mismatch.
Ariznawlll commentedon Jul 6, 2026
Additional View/CTAS deep-path coverage on latest main
781161fabagainst MySQL 8.0.45 confirms this tracker still covers the remaining CTAS metadata/materialization gaps.Newly checked shapes:
CTASoverUNION ALLwhere a later branch containsNULL: MySQL creates nullable columns; MO still fails during materialization withERROR 3819: constraint violation: Column 's' cannot be null.CTASover aggregates: values match, but metadata differs forCOUNT,SUM,AVGprecision/defaults (SUM(int)MySQLdecimal(32,0), MOBIGINT;AVG(decimal)MySQLdecimal(14,6), MODECIMAL(38,8)).CTASover window functions: values match, but metadata differs forROW_NUMBER()unsignedness/defaults and window aggregate precision.CTASoverIFNULL/COALESCE/CASE/CONCAT/NULLIF: values match, but nullability and varchar length inference still differ from MySQL.No new issue opened; these are the same CTAS schema inference/materialization family tracked here.
Ariznawlll commentedon Jul 27, 2026
补充 CTAS 默认值场景,使用两列最小表复现:
三次执行中,
DESC ctas_base均显示qty INT(32) NOT NULL DEFAULT 7,但最后一条插入均返回:
显式给出
qty时可写入;手工创建的同定义表省略qty可正确写入 7。MySQL 8.0.45 的 CTAS 目标显示默认值 7,省略
qty的插入成功并写入 7。这属于本单跟踪的 CTAS schema/default 使用路径差异,补充最小可复现用例,不新增同类 CTAS 单。
Ariznawlll commentedon Aug 20, 2026
最新
main592ad2190a90e063e3877059f4018427a10a4998上复核了该追踪项,并确认同一AVG返回类型规则也覆盖窗口查询和 JDBC 结果集元数据。在
TINYINT/SMALLINT/INT/BIGINT/DECIMAL(20,6)/DOUBLE输入上,普通聚合和AVG(...) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING)连续 3 轮一致:TINYINT/SMALLINT/INT的 AVG:DOUBLE(精度 53);MySQL:DECIMAL(scale 4)。BIGINT:DECIMAL(38,4);MySQL:DECIMAL(23,4)。DECIMAL(20,6):DECIMAL(38,12);MySQL:DECIMAL(24,10)。DOUBLE输入两端均为DOUBLE。例如整型值
1,2,4的窗口 AVG 第三行,MO 返回2.3333333333333335,MySQL 返回2.3333。在 16,387 行滑动窗口上,后续再对窗口 AVG 求和时,MO 和 MySQL 因逐行结果尺度不同产生819245.772383与819245.7728的差异。CREATE TABLE ... AS SELECT AVG(i) OVER (...)仍复现:MO 目标列为DOUBLE,MySQL 为DECIMAL(14,4);普通AVG(i)CTAS 也是同样结果。因此这属于本 tracker 已列的 aggregate/window CTAS 类型推导兼容性范围,不新增同类 Issue。daviszhen commentedon Aug 22, 2026
• 结论:Issue #24436 仍未解决,且当前没有关联 PR。原先拆出的 #24429~#24434 被关闭只是“合并回此 tracker”,不是已修复证据。Issue #24436
(#24436)
仍需处理的核心问题:
CTAS 聚合类型推导
AVG/SUM/COUNT/MAX/MIN 的精度、scale、默认值、NULL 属性与 MySQL 不一致;尤其 AVG 普通聚合和窗口聚合仍返回不同类型。最新复测
([Bug]: tracker for remaining CTAS schema inconsistencies with MySQL #24436 (comment))
BIT_AND/OR/XOR 的 CTAS 类型推导
需要统一结果类型、无符号属性、默认值和 NULL 属性。BIT_XOR(...) OVER (...) 还存在单独的语法/执行问题,应另开 PR 处理。[Bug]: BIT_XOR aggregate is rejected with an OVER clause #27342
([Bug]: BIT_XOR aggregate is rejected with an OVER clause #27342)
DECIMAL 类型
CREATE TABLE ... AS SELECT decimal_col 仍可能扩大 precision/scale,与 MySQL 不一致。
字符串函数类型
CONCAT_WS、CONCAT、IFNULL、COALESCE、CASE、NULLIF 的结果长度和 NULL 属性仍偏宽或不一致,常见为 MatrixOne 返回 VARCHAR(65535)。
时间函数类型
DATE_FORMAT 的结果列类型、长度和 NULL 属性需要对齐 MySQL;显式 DATETIME 表达式的 NULL/scale 也有差异。
CTAS 属性和默认值
([Bug]: tracker for remaining CTAS schema inconsistencies with MySQL #24436 (comment))
UNION 类型合并
UNION 分支的 DECIMAL/VARCHAR 宽度、NULL 属性与 MySQL 不一致;后续分支出现 NULL 时,CTAS 仍可能在物化阶段报 Column ... cannot be null。复测
([Bug]: tracker for remaining CTAS schema inconsistencies with MySQL #24436 (comment))
CTAS 元数据暴露
information_schema.columns 中可能出现 MatrixOne 内部的 __mo_fake_pk_col,需要确认是否应对用户隐藏。
已经单独解决、无需重复处理的相关问题:
建议将剩余工作拆成一个“CTAS 类型/属性推导统一”主 PR;视图元数据刷新、BIT_XOR OVER、排名函数 JDBC 无符号元数据分别处理为独立 PR(#26227
(https://github.com/matrixorigin/matrixone/issues/26227)、#27342 (https://github.com/matrixorigin/matrixone/issues/27342)、#27343
(https://github.com/matrixorigin/matrixone/issues/27343))。
fix: do not retain AUTO_INCREMENT in CTAS result columns (#27475)
daviszhen commentedon Aug 30, 2026
截至 2026-08-30,基于最新
maine8187087b6和本地新构建的mo-service重跑原始/最小 SQL 后,状态更新如下。本轮新确认已解决:
COUNT为BIGINT NOT NULL DEFAULT 0,BIT_AND/BIT_OR/BIT_XOR为BIGINT UNSIGNED NOT NULL DEFAULT 0,MAX/MIN保持 nullable。qty INT NOT NULL DEFAULT 7最小用例,CTAS 后省略qty的 INSERT 已成功并写入 7,旧的invalid default value不再复现。3819 Column ... cannot be null用例已可成功创表并写入 NULL。但 UNION common type 元数据仍未对齐,见下文。IFNULL/COALESCE/CASE/NULLIFCTAS 用例已不再推导为VARCHAR(65535);当前分别得到有界的VARCHAR(12)/VARCHAR(3)。这说明旧 comment 中的公共超宽问题已被后续控制流类型推导修复;新的特定表达式差异应使用具体 SQL 单独确认。本轮已提交:
format_length规则推导长度,保持可空,并保留表达式列名中带引号且大小写敏感的 format。原用例现为varchar(134) DEFAULT NULL,已补单测和 BVT;待 review/CI/合并。仍需处理,按建议优先级排序:
DECIMAL(38,0),MySQL 为DECIMAL(10,0)。这涉及 parser/DDL 全局语义,需要先评估存储和兼容影响。VARCHAR(65535) NOT NULL,MySQL 为VARCHAR(5) NULL。REVIEW_REQUIRED且 branch behind,建议等其更新/合并后再跑本 tracker 用例,避免重复实现。不再列为 remaining 的已解决项仍包括:CTAS AUTO_INCREMENT (#27475)、
__mo_fake_pk_col隐藏 (#27015)、显式 DATETIME CTAS (#26349)、BIT_XOR(...) OVER (...)(#27342)、#25389、#26825、#26826、#26828。fix(plan): align non-null aggregate CTAS defaults (#27865)
25 remaining items
Ariznawlll commentedon Oct 14, 2026
补充:动态长度 LPAD / RPAD / REPEAT 的 LONGTEXT 结果在 CTAS 中无法物化
在固定本地 MatrixOne runtime commit
2ce4e58af6f03b943ee288ffad81012766cf830a与 MySQL 8.0.46 对照。当前origin/main为944b721d1b3705cdb51d1e26f1a04611a08c8401,相关func_unary.go、list_builtIn.go和string_result_domain.go在两者间无变化。直接查询和 View 都在两端返回三个长度为 100000 的结果。View 的列类型为 MO
TEXT、MySQLLONGTEXT。但以下三条 CTAS 在 MO 上各自都返回:
MySQL 8.0.46 三条均成功,列类型为
LONGTEXT,物化后长度均为 100000。MO 失败的 CTAS 不留下目标表;View 查询仍能读取完整 100000 字符。因此这里不只是
TEXT/LONGTEXT元数据差异:动态长度表达式合法地产生超过 65535 字符的值,但 CTAS 将其按 65535 长度的 TEXT 目标物化而拒绝。该结果域/物化交叉属于本 CTAS schema tracker,不另开重复 issue。Ariznawlll commentedon Oct 14, 2026
补充同一 CTAS schema/materialization 问题的边界与 Prepared 复现(MatrixOne commit
2ce4e58af6f03b943ee288ffad81012766cf830a、MySQL 8.0.46):两端的标量长度均为 65,536;MySQL 三个 prepared CTAS 均成功并生成
LONGTEXT。MatrixOne 三个 CTAS 均在物化时以Src length 65536 is larger than Dest length 65535报错。边界控制:65,535 字符的同类 MatrixOne CTAS 成功,65,536 字符失败。与已有动态长度 100,000 字符复现是同一问题,不另开 issue。SPACE(65536)的函数级拒绝已单独记录在 #30186,这里不重复提报。Ariznawlll commentedon Oct 14, 2026
补充:SPACE() 常量表达式的 CTAS 列宽
在固定 MatrixOne runtime commit
2ce4e58af6f03b943ee288ffad81012766cf830a上,下面三条 CTAS 分别重复创建 3 次,information_schema.columns.column_type均为varchar(65535),但实际值长度均为 3:动态列参数
SPACE(n)推导为varchar(65535)是保守宽度;常量参数则不同。MySQL 8.0.46 的Item_func_space::resolve_type()会在参数可常量求值时调用set_data_type_string(count),所以SPACE(3)的表达式结果宽度为 3(参见 MySQL 8.0.46 实现)。本次没有可用的 MySQL runtime,故此处 MySQL 预期来自官方实现,待 live MySQL 再核对。这是 CTAS 的结果列元数据差异,不是函数值错误;与 #30186 的大结果长度限制相关但不同。请在处理 SPACE 大结果时一并考虑常量宽度推导,避免所有常量结果都退化为宽类型。归入本 tracker,不另开重复 issue。
Ariznawlll commentedon Oct 14, 2026
补充一组 ENUM/SET 与条件函数的 CTAS schema 交叉。MatrixOne 本地 runtime build
2ce4e58af6f03b943ee288ffad81012766cf830a(8.0.30-MatrixOne-v1.3.0)与 MySQL 8.0.45 对照,三次重建 CTAS 的元数据结果一致:\n\nsql\nCREATE TABLE src(id INT, e ENUM('red','blue'), s SET('a','b'));\nINSERT INTO src VALUES (1,'red','a,b'),(2,'blue','b'),(3,NULL,NULL);\nCREATE TABLE out_types AS\nSELECT e AS src_e, COALESCE(e,e) AS co_e, IFNULL(e,e) AS ifnull_e,\n IF(id=1,e,e) AS if_e, CASE WHEN id=1 THEN e ELSE e END AS case_e,\n COALESCE(s,s) AS co_s\nFROM src;\nSELECT column_name,data_type,column_type\nFROM information_schema.columns\nWHERE table_name='out_types' ORDER BY ordinal_position;\n\n\nMySQL 推导co_e/ifnull_e/if_e/case_e为VARCHAR(4),co_s为VARCHAR(3);MO 将这些条件函数结果列均固化为VARCHAR(65535)。源 ENUM 列在两端均保留ENUM('red','blue')。实际值red/blue、a,b/b及 NULL 行一致;差异仅在 CTAS 结果元数据。该用例补充了现有条件函数 CTAS 类型推导记录中的 ENUM/SET 输入分支。Ariznawlll commentedon Oct 14, 2026
补充:
FROM_BASE64()的 CTAS 结果列类型在 MatrixOne 本地单机 runtime
8.0.30-MatrixOne-v1.3.0(source commit2ce4e58af6f03b943ee288ffad81012766cf830a)与隔离 MySQL8.0.45上,使用含NULL、有效 Base64 文本和空串的VARCHAR(8)源列,各自新建 3 张目标表重复验证:三轮中,源值及两种函数的物化结果都一致,NULL 也被保留。
TO_BASE64(v)的 CTAS 列类型两端相同(VARCHAR(44) NULL);FROM_BASE64(v)则为 MySQLVARBINARY(24) NULL、MOLONGBLOB NULL。这是 CTAS 结果类型推导差异,不是本次观察到的字节值错误;补充到现有 CTAS schema tracker,不另开重复 issue。Ariznawlll commentedon Oct 14, 2026
补充:日期/时间提取函数交叉 CTAS 的结果类型
MatrixOne 本地 runtime
8.0.30-MatrixOne-v1.3.0(source commit2ce4e58af6f03b943ee288ffad81012766cf830a)与隔离 MySQL8.0.45对照。以DATE和DATETIME(6)源列物化下列函数,各自连续创建 3 张新 CTAS 表;每轮结果类型稳定,所有函数值相同:以下列型差异在 3 张目标表上都一致(省略的列型两端相同):
DAYOFWEEK,WEEKDAY,YEAR,WEEKOFYEAR,YEARWEEK,DATEDIFF,TO_DAYSINTBIGINTQUARTER,MONTH,DAYOFMONTH,HOUR,MINUTE,SECOND,TIME_TO_SECINTTINYINT UNSIGNED或BIGINT(见函数)UNIX_TIMESTAMP(DATETIME(6))DECIMAL(17,6)DECIMAL(38,6)两端的物化值均相同,例如
2024-12-31 23:59:58.123456得到相同的周、年日、时间字段及1735660798.123456Unix 时间值。这是函数结果类型经 CTAS 持久化后的 metadata 差异,不是本次观察到的值错误;补充在现有 CTAS schema tracker 中,不另开 issue。Ariznawlll commentedon Oct 14, 2026
补充:精确整数
SUM()的 CTAS 返回类型在现有“聚合函数 CTAS”范围内,进一步对照了整数类型族及大值求和。环境为 MatrixOne 本地服务
8.0.30-MatrixOne-v1.3.0(服务源码 commit2ce4e58af6f03b943ee288ffad81012766cf830a)与隔离 MySQL8.0.45。源表分别包含 TINYINT、SMALLINT、MEDIUMINT、INT、BIGINT、BIGINT UNSIGNED,输入为
1, 2, 3, NULL。在两端各建立 3 组 CTAS 输出表后,information_schema.columns.column_type每轮都稳定为:SUM(TINYINT)DECIMAL(25,0)BIGINTSUM(SMALLINT)DECIMAL(27,0)BIGINTSUM(MEDIUMINT)DECIMAL(30,0)BIGINTSUM(INT)DECIMAL(32,0)BIGINTSUM(BIGINT)DECIMAL(41,0)DECIMAL(38,0)SUM(BIGINT UNSIGNED)DECIMAL(42,0)DECIMAL(38,0)值控制未发现差异:普通数据上六种
SUM均返回6;两行BIGINT最大值相加,两端均返回18446744073709551614;两行BIGINT UNSIGNED最大值相加,两端均返回36893488147419103230。SUM(i) + CAST('0.000000000000000001' AS DECIMAL(20,18))的值也一致。当前证据指向精确整数聚合的结果类型/CTAS 元数据不一致,不是本组已观察到的求和值错误。MySQL 8.0 文档说明
SUM()对 exact-value 输入(整数或 DECIMAL)返回 DECIMAL:Aggregate Function Descriptions。兼容性契约的聚合元数据章节目前只记录GROUP_CONCAT的明确类型例外,没有登记整数SUM的上述差异;因此把证据补到本 CTAS 汇总 issue,不另开重复 issue。本轮未新增测试文件。Ariznawlll commentedon Oct 14, 2026
补充:COUNT(DISTINCT) CTAS 列的可空性
在 MySQL
8.0.45与 MatrixOne 本地服务 commit2ce4e58af6f03b943ee288ffad81012766cf830a上,将二进制列控制与_ci值差异分开检查。对同一组含重复值及 NULL 的输入,分别创建 3 张 CTAS 输出表:三轮中,表达式的值在两端都是
4,列类型也都是BIGINT;但 MySQLis_nullable='NO',MOis_nullable='YES'。该列源自COUNT(DISTINCT ...),空集仍返回0,不会返回 NULL。这个可空性差异属于 #24436 已覆盖的聚合函数 CTAS 元数据范围;另一个_ci去重值差异已补至 #25096。本轮未新建 issue 或测试文件。Ariznawlll commentedon Oct 14, 2026
新增 CTAS 案例:
LEAST/GREATEST对非空输入的可空性推导环境: MatrixOne
8.0.30-MatrixOne-v1.3.0(服务源码 commit2ce4e58af6f03b943ee288ffad81012766cf830a),对照 MySQL8.0.45。观察到的值: 两端
GREATEST=2.0000、LEAST=1.0000。CTAS 结构与后续写入: 三次独立重建均一致:
g/lDECIMAL(12,4) NOT NULL DEFAULT '0.0000'DECIMAL(12,4) DEFAULT NULLNULLERROR 1048: Column 'g' cannot be nullg IS NULL、l IS NULL均为1直接查询的列协议元数据同样显示 MySQL 有
NOT_NULL,MO 无此标志。结果值本身一致;差异在函数结果可空性如何传入 CTAS,并进一步改变目标表允许写入的数据。这与 #26830 已修复的“函数可能由非 NULL 输入产生 NULL,却错误标记为 NOT NULL”方向相反。本例的输入列显式为
NOT NULL DECIMAL;服务源码function.DeduceNotNullable对GREATEST/LEAST当前无条件保守返回 nullable(runtime source)。作为现有 CTAS schema 推导差异的具体案例补入本 tracker;未新增独立 issue 或测试文件。Ariznawlll commentedon Oct 21, 2026
补充同一 CTAS / set operation 类型推导问题的二进制边界。两支输入都是
VARBINARY(8),没有混合类型;MO 的UNION ALL/INTERSECT ALL结果经 CTAS 却变成LONGBLOB。这不只影响元数据:目标表随后接受 9 字节值,而源表和 MySQL 目标表都拒绝。3a1e42b430a,c_plainVARBINARY(8)VARBINARY(8)c_union,c_intersectLONGBLOBVARBINARY(8)a的 9 字节写入两端都拒绝(MO 报20101 Can't cast,MySQL 报1406 Data too long)。c_union的 9 字节写入 MySQL 同样拒绝,MO 则成功,随后HEX(b)能读出完整001122334455667788。原有00FF/FF00值和INTERSECT ALL的交集值两端一致。对每端 3 个全新数据库重复,54 项结构、值、边界和错误后可用性检查全部得到上述结果;不是脏数据或缓存滞后。白盒线索:
pkg/sql/plan/query_builder.go的 set-operation 共同类型分支仅在部分 grouping 条件下保留同型 BINARY/VARBINARY 的宽度,否则将目标类型提升为 BLOB(约 4830–4853 行)。本例与本 tracker 已记录的 UNION/CTAS 类型推导属于同一类,因此补充在这里,不另开重复 issue。XuPeng-SH commentedon Oct 23, 2026
Two more CTAS type-inference rows measured on current
main(3ad9adbb4c, macOS arm64) that are not yet listed in this tracker.Measured (MO) vs MySQL 8:
1bigintint1.5decimal(2,1)decimal(2,1)'x'varchar(1)varchar(1)now()timestampdatetimecast(1 as unsigned)bigint unsignedbigint unsignednow()→timestampis the one worth prioritising:TIMESTAMPcarries timezone-conversion semantics (and a conversion at read/write time) thatDATETIMEdoes not, so a table built with CTAS silently gets a column whose values shift withtime_zone, while the same statement on MySQL produces aDATETIME. On the1→bigintrow the effect is only storage/range width, but it also changes whatinformation_schema.columnsreports for downstream tooling that infers types from a CTAS.Reproduction is fully deterministic (no data dependency); both rows reproduce in a fresh database.
Ariznawlll commentedon Oct 29, 2026
结论
测试不通过。本 issue 已跟踪的
COUNT(DISTINCT ...)可空元数据差异,还会通过 Python SDK 的 Arrow 查询与建表传递成目标列约束差异;本次没有观察到聚合结果值错误。关键证据
版本:
main@c6683bd2f531dcaa80e153c0924dac619c49dc9d,同提交构建的隔离双 CN;MySQL 8.0.45 对照。3 个新建库、两个 CN 分别验证。数据:
src(id INT PRIMARY KEY,x INT,y INT),行(1,1,2),(2,NULL,3),(3,1,2),(4,NULL,NULL)。查询:两端结果均为
(4,1,1,1),但 MO 协议元数据将c_dist/c_multi标为可 NULL,MySQL 标为非 NULL;COUNT(*)和MAX对照的非空标记一致。空集和全 NULL 输入的实际 COUNT 仍为 0,结果值对齐。同一查询经
client.analytics.query(...).to_arrow()获取默认 Arrow schema,再upload_arrow(..., create=True)建表:MO 目标c_dist/c_multi均变成可 NULL,插入c_dist=NULL6/6 成功。显式指定两个 Arrow 字段非空后,同样建表和写入对照 6/6 正确拒绝,原始(4,1,1,1)保留;源表不变,连接可用,暂存文件清理。同查询的 CTAS 对照:MO 3/3 为可 NULL 并接受后续 NULL,MySQL 3/3 为非 NULL 并拒绝。该现象扩展了本 issue 先前的 COUNT DISTINCT CTAS 范围;新增的是协议元数据经 SDK Arrow 物化后的可观察影响,不是另报一个数据错误。
SDK Arrow schema 推导 使用协议非空标记;该标记在混合聚合计划中的具体丢失环节仍待定位。完整记录
sdk_agg8_count_metadata.json、sdk_agg8_count_impact.json。待解决点
fix(plan): preserve CTAS output nullability on 4.1.6 hotfix (#32085)
XuPeng-SH commentedon Nov 29, 2026
Consolidated #31158 into this CTAS inferred-type tracking scope.
Additional acceptance evidence retained:
CREATE TABLE ct1 AS SELECT 1 AS aandCREATE TABLE ct3 AS SELECT 1 + 1 AS ainferBIGINTin MatrixOne, while MySQL 8.0.45 infersINTfor both.CREATE TABLE src(id INT); CREATE TABLE ct6 AS SELECT id FROM srcpreservesINT.BIGINTcolumns and expressions as a negative control; the fix must not narrow every integer result indiscriminately.Administrative consolidation only. The existing unresolved CTAS metadata failures remain open; this is not a fix or QA-verification claim.