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
[Compatibility]: JSON constructors omit zero fractional seconds for TIME and DATETIME values #28056
When JSON constructors receive TIME(0) or DATETIME(0) values, MatrixOne serializes them without a fractional component. MySQL 8 serializes the same values in JSON with six zero fractional digits. This changes the JSON string value seen by JSON_EXTRACT/JSON_UNQUOTE, so equality, ordering, generated columns, and indexes built from that value can differ across the two systems.
Environment
Branch: main
Commit: 95d04586eb80864499d0fde27aeb912b463ae4cd
Deployment: local single-CN MatrixOne
Steps to reproduce
SELECT
JSON_UNQUOTE(JSON_EXTRACT(
JSON_OBJECT('tm', CAST('04:05:06.123456'ASTIME)), '$.tm')) AS tm,
JSON_UNQUOTE(JSON_EXTRACT(
JSON_OBJECT('dt', CAST('2024-02-03 04:05:06.123456'AS DATETIME)), '$.dt')) AS dt;
Actual behavior
MatrixOne returns:
04:05:06 | 2024-02-03 04:05:06
MySQL 8 returns:
04:05:06.000000 | 2024-02-03 04:05:06.000000
The same MatrixOne behavior occurs through JSON_OBJECT and JSON_ARRAY.
Expected behavior
For compatibility with MySQL JSON constructors, TIME(0) and DATETIME(0) values should be represented in JSON with .000000 rather than omitting the fractional component.
Stability and controls
Reproducer: 3/3 on MatrixOne main.
Explicit precision control: CAST(... AS TIME(6)) and CAST(... AS DATETIME(6)) preserve .123456 in both MatrixOne and MySQL 8, including after JSON extraction.
Ordinary SQL cast control: both systems display TIME(0)/DATETIME(0) without a fractional component outside JSON; the difference is confined to JSON serialization.
pkg/sql/plan/function/func_builtin_json.go converts TIME, DATETIME, and TIMESTAMP through String2(fromType.Scale) before creating typed JSON values. With scale 0, that produces text without .000000.
Regression coverage
After a fix, add a deterministic SQL regression covering TIME(0), DATETIME(0), and explicit scale controls through JSON_OBJECT, JSON_ARRAY, and JSON_SET.
Automation checkpoint: merged PR #28093 is being validated against current upstream/main 6d44c50. This issue remains open in phase/testing; no terminal tester PASS has been recorded in the current handoff. Please report complete version, environment, scoped scenario results, and terminal PASS/FAIL evidence before any closure decision.
Activity
Ariznawlll commentedon Sep 3, 2026
补充影响范围:
JSON_ARRAYAGG对TIME(0)和DATETIME(0)也出现同一 JSON 文本差异。Ariznawlll commentedon Sep 3, 2026
再补充 TIMESTAMP 与时区范围:
在会话
+00:00插入TIMESTAMP '2024-02-03 04:05:06',切换到+08:00后,MO 和 MySQL 的普通 TIMESTAMP 读取都为2024-02-03 12:05:06,说明时区换算正确。\n\n但JSON_OBJECT('ts', ts)经提取后,MO 连续三次为2024-02-03 12:05:06,MySQL 8 为2024-02-03 12:05:06.000000。\n\n因此 #28056 同时涉及 TIME、DATETIME、TIMESTAMP 的 scale-0 JSON 序列化;时间值的时区转换本身未见偏差。fix(json): unify constructor value conversion (#28093)
VioletQwQ-0 commentedon Sep 8, 2026
【QA 交接|PR #28093 已合并】
关联合并:PR #28093(merge commit 8836fb4);当前 main=1cfec4c80134adc5640a3bbf1aef7aaa87a45282。
本次范围:JSON_OBJECT、JSON_ARRAY、JSON_SET 及相关聚合入口对 TIME/DATETIME/TIMESTAMP scale-0 值的 MySQL 兼容序列化,期望保留六位小数;TIMESTAMP 必须按 session timezone 转换但保留 DATETIME JSON atom 语义。请覆盖普通入口、JSON_ARRAYAGG、+00:00/+08:00 时区切换、NULL/预编译路径、单 CN 与多 CN、重启后读取。
合并后证据:PR required checks 无失败;本地 exact-main CGo 自测因缺少 cgo/libmo.dylib 阻塞,mo-tester 未安装,未宣称本地 PASS。
请在合并版本连续复验上述场景;PASS 标准是结果与 MySQL 8 完全一致,FAIL 时请保留 SQL、main SHA、重复轮次和实际/期望结果。
VioletQwQ-0 commentedon Sep 8, 2026
补充 pin:远端 main 已推进到 9f87b62。请以该当前 main 复验;此前列出的合并提交、测试范围和 PASS/FAIL 标准保持不变。该更新不代表 QA PASS。
VioletQwQ-0 commentedon Sep 8, 2026
再次补充 pin:远端 main 已推进到 9cedf6e。请以该当前 main 复验;此前列出的合并提交、测试范围和 PASS/FAIL 标准保持不变。该更新不代表 QA PASS。
VioletQwQ-0 commentedon Sep 8, 2026
Automation checkpoint: merged PR #28093 is being validated against current upstream/main 6d44c50. This issue remains open in phase/testing; no terminal tester PASS has been recorded in the current handoff. Please report complete version, environment, scoped scenario results, and terminal PASS/FAIL evidence before any closure decision.
Ariznawlll commentedon Sep 9, 2026
测试版本
maina9d3b8b857c44f1249e682c91d4d62a914eb7d20原问题验证
验证 temporal 值写入 JSON object、array 和 set 时的小数秒精度及类型语义。
Happy Path 覆盖
.000000;scale 6 的值保留原微秒;Unhappy Path 覆盖
本 issue 的核心是合法 temporal 的精度编码;以 scale 0 与 scale 6 作为两端边界,确认不会丢失微秒或将零精度编码为非时间值。
白盒验证
不适用:通过 JSON 文本和容器查询结果验证外部契约。
回归测试
suites/14_issue_regression/t/issue_28056_28057_28058_28060_json_constructor_types.test。--record --repeat 3和非 record--repeat 3均通过;PR 共 21/21 用例、321/321 条语句成功。测试证据
时间类型、两个精度端点和三种 JSON 容器均重复 3 次。
测试结论
测试通过。
fix(json): unify constructor value conversion (matrixorigin#28093)
fix(json): unify constructor value conversion (matrixorigin#28093)
fix(json): unify constructor value conversion (matrixorigin#28093)