You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: CTAS cannot reparse TIMESTAMPADD unit syntax #28121
TIMESTAMPADD works in a regular SELECT and in a view, but fails in CREATE TABLE ... AS SELECT (CTAS). CTAS re-serializes the unit as a quoted string such as "hour"; its internal statement then fails to parse.
Environment
MatrixOne official main: 99ed717b769e261b842c2f17345bd65865fc1470
Clean local single-CN build and isolated data directory
Reproduced identically in 3/3 runs
Reproduction
CREATETABLEsrc (id INTPRIMARY KEY, dt DATETIME(6) NOT NULL);
INSERT INTO src VALUES (1, '2024-01-01 00:00:00.123456');
SELECT TIMESTAMPADD(HOUR, 1, dt) FROM src;
-- 2024-01-01 01:00:00.123456CREATETABLEctas_timestampaddASSELECT TIMESTAMPADD(HOUR, 1, dt) AS v FROM src;
The same result occurs with a DAY unit and for TIMESTAMP input.
Scope control
The equivalent view is created and queried successfully:
CREATEVIEWvASSELECT TIMESTAMPADD(HOUR, 1, dt) AS v FROM src;
SELECT*FROM v;
-- 2024-01-01 01:00:00.123456
DATE_ADD(..., INTERVAL 1 HOUR) CTAS is also a successful control. This isolates the failure to CTAS's serialization/reparse of TIMESTAMPADD, rather than the function evaluator or general derived-table use.
Preliminary code observation
CTAS formats the source SELECT and reparses it as an internal INSERT ... SELECT. The reserialized TIMESTAMPADD unit becomes a quoted string (for example "hour"), while the parser expects the unit token form. restoreIntervalSyntaxForCTAS restores interval(value, unit) syntax but does not cover TIMESTAMPADD(unit, value, expression). This is an observation of the failing path, not a proposed fix.
Suggested regression coverage
Add CTAS cases for TIMESTAMPADD with HOUR and DAY units, with both DATETIME(6) and TIMESTAMP(6) input; keep normal SELECT and view cases as controls.
不适用:问题是合法 TIMESTAMPADD unit 在 CTAS 内部序列化后不可解析,不是用户非法 SQL。建表、物化和读取成功覆盖了原先的失败重解析点。
白盒验证
执行 go test -vet=off ./pkg/sql/plan -run 'TestCreateTableAsSelectUsesTemporalASTSyntax|TestCreateTableAsSelectWithTemporalFractionalSeconds' -count=1,通过。
Activity
fix temporal precision, prepared binding, and boundary semantics (#28316
jiangxinmeng1 commentedon Sep 14, 2026
fixed by #28316
Ariznawlll commentedon Sep 14, 2026
测试版本
mainbe30a70fe50eac4e8c78e5117fdd69179ba853e0mo-service,独立数据目录原问题验证
以含
DATETIME(6)与TIMESTAMP(6)的源表执行CREATE TABLE ... AS SELECT TIMESTAMPADD(HOUR, 1, dt), TIMESTAMPADD(DAY, 1, ts)。连续 3 次均完成 CTAS;此前被重新格式化为带引号 unit 的内部 SQL 不再报语法错误。Happy Path 覆盖
TIMESTAMPADD(HOUR, 1, dt)物化为2024-03-10 07:30:00.123456。TIMESTAMPADD(DAY, 1, ts)物化为2024-03-11 06:30:00.123456。123456微秒,覆盖不同 unit 与两类时态输入。Unhappy Path 覆盖
不适用:问题是合法
TIMESTAMPADDunit 在 CTAS 内部序列化后不可解析,不是用户非法 SQL。建表、物化和读取成功覆盖了原先的失败重解析点。白盒验证
执行
go test -vet=off ./pkg/sql/plan -run 'TestCreateTableAsSelectUsesTemporalASTSyntax|TestCreateTableAsSelectWithTemporalFractionalSeconds' -count=1,通过。回归测试
issue_28121_28123_28124_28122_28144_temporal_ctas.test./motr --repeat 3 14_issue_regression.issue_28121_28123_28124_28122_28144_temporal_ctas:3/3 通过,66/66 statements。测试证据
定向结果与预期基线见 MOTR PR #170。该 case 在
14_issue_regression套件实跑中为 22/22 statements 通过;套件内其他既有 case 的失败未修改。测试结论
测试通过。
fix temporal precision, prepared binding, and boundary semantics (mat…
fix temporal precision, prepared binding, and boundary semantics (mat…
fix temporal precision, prepared binding, and boundary semantics (mat…