Repository navigation
Description
Description
GROUP_CONCAT bypasses MatrixOne's normal temporal display conversion:
DATETIME(p)andTIME(p)values lose all fractional-second digits when passed directly to the aggregate.TIMESTAMP(p)values are rendered as internal UTC timestamps with aUTCsuffix, ignoring the session time zone used by direct SELECT and CAST.
The stored values and explicit CAST(... AS CHAR) results are correct. Only the aggregate's direct temporal formatting changes the data.
Environment
- Branch:
main - Commit:
e7d46d6dfb27696211ca828c55e245d3bd1b634d - Deployment: local standalone (
1 CN / 1 TN / 1 LogService) - Oracle: MySQL 8.3.0, isolated local instance
Steps to reproduce
drop database if exists gc_fractional_temporal;
create database gc_fractional_temporal;
use gc_fractional_temporal;
set session time_zone = '+08:00';
create table src (
id int primary key,
dt3 datetime(3),
dt6 datetime(6),
tm3 time(3),
tm6 time(6),
ts3 timestamp(3),
ts6 timestamp(6)
);
insert into src values
(1, '2024-01-02 03:04:05.120', '2024-01-02 03:04:05.123456',
'12:34:56.120', '12:34:56.123456',
'2024-01-02 03:04:05.120', '2024-01-02 03:04:05.123456'),
(2, '2024-01-03 04:05:06.007', '2024-01-03 04:05:06.000007',
'-01:02:03.004', '-01:02:03.000004',
'2024-01-03 04:05:06.007', '2024-01-03 04:05:06.000007');
select id, dt3, dt6, tm3, tm6, ts3, ts6 from src order by id;
select group_concat(dt3 order by id separator '|') from src;
select group_concat(dt6 order by id separator '|') from src;
select group_concat(tm3 order by id separator '|') from src;
select group_concat(tm6 order by id separator '|') from src;
select group_concat(ts3 order by id separator '|') from src;
select group_concat(cast(ts3 as char) order by id separator '|') from src;
set session time_zone = '+00:00';
select id, ts3, cast(ts3 as char) from src order by id;
select group_concat(ts3 order by id separator '|') from src;
select group_concat(cast(ts3 as char) order by id separator '|') from src;Actual behavior
Representative MatrixOne results:
dt3: 2024-01-02 03:04:05|2024-01-03 04:05:06
dt6: 2024-01-02 03:04:05|2024-01-03 04:05:06
tm3: 12:34:56|-01:02:03
tm6: 12:34:56|-01:02:03
TIMESTAMP at session +08:00:
direct/cast: 2024-01-02 03:04:05.120
GROUP_CONCAT: 2024-01-01 19:04:05.120000 UTC
TIMESTAMP at session +00:00:
direct/cast: 2024-01-01 19:04:05.120
GROUP_CONCAT: 2024-01-01 19:04:05.120000 UTC
The aggregate TIMESTAMP string is invariant across session time-zone changes and exposes the internal UTC representation.
Expected behavior
Direct temporal arguments should use the same textual conversion as the corresponding value in the current session:
- preserve the declared fractional-second scale for
DATETIME(p),TIME(p), andTIMESTAMP(p); - convert
TIMESTAMPthrough the active session time zone; - do not append an internal
UTCsuffix.
MySQL 8.3.0 produces the same text as CAST(... AS CHAR) for all these probes.
Stability and controls
- Reproducer: 3/3 for scale 3 and 6 across DATETIME, TIME, and TIMESTAMP.
- Time-zone matrix: 3/3 at
+08:00and+00:00. - Storage control: direct SELECT preserves every inserted fractional digit.
- Conversion control:
GROUP_CONCAT(CAST(value AS CHAR))preserves scale and session time-zone conversion in MatrixOne. - Scale-0 control:
DATETIME,TIME, and MySQL TIMESTAMP values without fractions render as expected. - MySQL 8.3.0 oracle: direct aggregate and explicit-cast aggregate results are identical in 3/3 runs.
- Failure atomicity: all probes are read-only and leave source rows unchanged.
Evidence
The complete result files for all three MatrixOne runs are byte-identical, as are all three MySQL runs. Representative output is included above.
Code analysis
pkg/sql/colexec/aggexec/agg_payload.go::writeGroupConcatData formats temporal payloads directly:
case types.T_datetime:
return writeValue(util.UnsafeFromBytes[types.Datetime](data).String())
case types.T_timestamp:
return writeValue(util.UnsafeFromBytes[types.Timestamp](data).String())
case types.T_time:
return writeValue(util.UnsafeFromBytes[types.Time](data).String())These calls have no declared scale and no session time-zone context. They therefore differ from the normal expression/vector-to-text conversion used by direct SELECT and explicit CAST. The aggregate needs the same scale-aware and session-aware temporal formatting path rather than raw internal String() methods.
Regression coverage
After the fix, add focused aggregate-executor tests for scale 0/3/6 and SQL regression coverage for direct vs explicit-cast aggregation at two session time zones. Include ordered and grouped forms so merge/serialization paths cannot reintroduce the raw internal format.
Related
- [Feature Request]: support sub-second units in Time Window aggregation #26983 adds sub-second units for Time Window aggregation; it does not cover
GROUP_CONCATformatting. - [Compatibility]: GROUP_CONCAT truncation does not emit MySQL warning 1260 #28252/fix(sql): report group concat truncation warnings #28504 cover truncation warnings, not temporal conversion.
Activity
Ariznawlll commentedon Sep 11, 2026
补充影响:时间精度丢失也会使
GROUP_CONCAT(DISTINCT ...)的输出在文本层面自相矛盾。当前 main
e7d46d6dfb27696211ca828c55e245d3bd1b634d上,四个互不相同的DATETIME(6)值:执行:
MatrixOne 返回:
DISTINCT按原始时间值保留了四项,但GROUP_CONCAT在输出转换时去掉了微秒,因而结果中出现三个完全相同的文本项。TIME(6)也有相同行为:原始 distinct count 为 4,输出前三项都变成03:04:05。MySQL 8.3.0 保留声明的六位精度:
该现象在同一 2-CN 本地分布式环境连续 3 次一致。问题不只是显示差异:下游按分隔符解析
GROUP_CONCAT(DISTINCT temporal)时,无法恢复或区分已经通过 DISTINCT 的原始值。Ariznawlll commentedon Sep 11, 2026
最新
main065a67528608c475d0219e0be6b7d454a58f7b1a复核:四个不同的DATETIME(6)/TIME(6)值经GROUP_CONCAT(DISTINCT ... ORDER BY ...)后,前三项仍被格式化成完全相同的秒级文本;原始COUNT(DISTINCT)仍为 4。连续 3 次一致。fix: preserve temporal scale and timezone in group_concat (#28701)
Ariznawlll commentedon Sep 14, 2026
测试版本
mainbb358ea76aeb44a6eed5079616e7e75ba35e75b9原问题验证
对
DATETIME(6)、TIME(6)、TIMESTAMP(6)比较GROUP_CONCAT(value)与GROUP_CONCAT(CAST(value AS CHAR))。连续 3 轮三个比较均为1;微秒没有丢失,也没有暴露内部UTC后缀。Happy Path 覆盖
DATETIME(6)和正负TIME(6)的 aggregate/cast 文本完全一致。TIMESTAMP(6)在+00:00下与显式 CAST 一致;切换至+08:00后,SQL PREPARE 路径返回按会话时区转换的2024-01-02 03:04:05.123456|2024-01-02 03:04:06.654321。Unhappy Path 覆盖
该问题没有应拒绝的输入;时间精度、负 TIME 与时区切换均为有效边界,已作为兼容性控制覆盖。测试只读,不修改源数据。
白盒验证
test/distributed/cases/function/group_concat_temporal.sql已存在对应 SQL 回归;实现修复为 matrixone#28701。本轮以公开 SQL 验证格式化与会话时区链路。回归测试
已加入 motr#169:
suites/14_issue_regression/t/issue_28579_28593_28595_28653_28657_28669_compatibility.test。定向用例连续 3/3 通过,共 150/150 statements。测试证据
6817c73d112d012ae784cbb9c0fc9b515a313e4fd1b1057f0abd7ea15125b9f6(3 轮一致)。测试结论
测试通过。
fix: preserve temporal scale and timezone in group_concat (matrixorig…
fix: preserve temporal scale and timezone in group_concat (matrixorig…
fix: preserve temporal scale and timezone in group_concat (matrixorig…