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
EXTRACT(unit FROM temporal_expression) works in a normal query but fails in CREATE TABLE ... AS SELECT (CTAS). CTAS reserializes the date-part unit in a form that its internal statement cannot 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 EXTRACT(HOUR FROM dt) FROM src;
-- 0CREATETABLEctas_extractASSELECT EXTRACT(HOUR FROM dt) AS v FROM src;
Actual result:
ERROR 1105 (HY000): syntax error ... near ', `src`.`dt`) as `v` ...'
Scope control
In the same CTAS matrix, these expressions successfully create a table and preserve their values:
This isolates the issue to the EXTRACT CTAS serialization/reparse path, rather than CTAS over temporal functions in general.
Preliminary code observation
The parser's canonical representation lowers EXTRACT(HOUR FROM dt) to a function-like form. CTAS formats the source SELECT then reparses it, and the generated representation does not remain valid EXTRACT syntax. This is a diagnosis hypothesis, not a proposed fix.
Suggested regression coverage
Add CTAS coverage for EXTRACT date and time units (YEAR, HOUR, MICROSECOND) over DATE, DATETIME(6), and TIMESTAMP(6), with direct SELECT controls.
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) '2024-03-10 06:30:00.123456'执行 CTASEXTRACT(YEAR/HOUR/MICROSECOND FROM dt);连续 3 次均可完成建表和查询,结果为2024, 06, 123456,不再出现 CTAS 内部 SQL 重解析语法错误。Happy Path 覆盖
YEAR、时间单位HOUR以及精度单位MICROSECOND。2024:06:123456,与源时间一致。Unhappy Path 覆盖
不适用:问题是合法
EXTRACT语法在 CTAS 内部序列化后不可解析,不是用户非法 SQL。成功创建与回读共同验证了内部重解析路径。白盒验证
执行
go test -vet=off ./pkg/sql/plan -run 'TestCreateTableAsSelectUsesTemporalASTSyntax' -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…