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 persists fractional TIME values in an unscaled TIME column #28127
CTAS can persist fractional seconds in a column declared as unscaled TIME. This violates the declared FSP contract: direct INSERT ... SELECT into the same TIME/TIME(0) target truncates the fraction, while CTAS stores it.
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 07:08:09.123456');
CREATETABLEctas_timeASSELECTTIME(dt) AS v FROM src;
SHOW CREATE TABLE ctas_time;
SELECT v FROM ctas_time;
Actual result:
CREATE TABLE `ctas_time` (`v` time NOT NULL)
07:08:09.123456
Scope control
The normal target-insert path respects the same FSP contract:
CREATETABLEt0 (v TIMENOT NULL);
CREATETABLEt6 (v TIME(6) NOT NULL);
INSERT INTO t0 SELECTTIME(dt) FROM src;
INSERT INTO t6 SELECTTIME(dt) FROM src;
SELECT v FROM t0; -- 07:08:09SELECT v FROM t6; -- 07:08:09.123456
Likewise, direct literal INSERT into TIME/TIME(0) rounds to whole seconds. The unexpected behavior is the CTAS path retaining precision that its own synthesized schema does not declare.
Expected behavior
CTAS must either declare TIME(6) for this expression or coerce the inserted value to the declared unscaled TIME precision. Schema metadata and persisted value must agree.
Preliminary code observation
The TIME() evaluator returns a value carrying source fractional precision at runtime, while CTAS derives an unscaled TIME target schema from static metadata. Its generated insert appears not to apply the same target-scale coercion as normal INSERT ... SELECT. This is a diagnosis hypothesis, not a proposed fix.
Suggested regression coverage
Compare CTAS and INSERT ... SELECT into TIME, TIME(0), and TIME(6) for a TIME(DATETIME(6)) expression; assert both column metadata and stored values.
Tracking consolidated into #24436. The canonical issue includes this report's independent scope and acceptance criteria. This is administrative consolidation, not a claim that the defect is fixed. The original reproduction and discussion remain preserved here.
Activity
XuPeng-SH commentedon Oct 24, 2026
Tracking consolidated into #24436. The canonical issue includes this report's independent scope and acceptance criteria. This is administrative consolidation, not a claim that the defect is fixed. The original reproduction and discussion remain preserved here.