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]: VAR_* and STDDEV_* reject MySQL numeric-convertible character and temporal operands #28229
MatrixOne 的 VAR_POP、VAR_SAMP、STDDEV_POP、STDDEV_SAMP(以及别名 VARIANCE、STD、STDDEV)只接受原生数值类型。VARCHAR、DATE、DATETIME 列在函数绑定阶段被拒绝,因此相同 SQL 无法从 MySQL 迁移。
MySQL 8.3 会按其数值转换规则处理这些类型:数值字符串转为对应数值,日期和日期时间转为数字形式后计算。该行为同时适用于普通聚合、窗口聚合和 prepared statement。
环境
MatrixOne: official main
commit: e7bb0572235ec4bac81eb098eb0ad8900f0065ab
comparison: MySQL 8.3
复现
createdatabasestat_agg_type_repro;
use stat_agg_type_repro;
createtablet(
id intprimary key,
s varchar(20),
d date,
ts datetime
);
insert into t values
(1, '1', '2024-01-01', '2024-01-01 01:02:03'),
(2, '2', '2024-01-02', '2024-01-02 02:03:04'),
(3, '3', '2024-01-03', '2024-01-03 03:04:05');
select var_pop(s), var_samp(s), stddev_pop(s), stddev_samp(s) from t;
select var_pop(d), var_samp(d), stddev_pop(d), stddev_samp(d) from t;
select var_pop(ts), var_samp(ts), stddev_pop(ts), stddev_samp(ts) from t;
select id,
var_pop(s) over(order by id rows between unbounded preceding and current row)
from t order by id;
prepare p from'select var_pop(s), stddev_samp(s) from t';
execute p;
MatrixOne 对前三组查询分别返回:
invalid argument aggregate function var_pop, bad value [VARCHAR]
invalid argument aggregate function var_pop, bad value [DATE]
invalid argument aggregate function var_pop, bad value [DATETIME]
Topology: one Log Service, one TN, two CN services, and one Proxy, all from the locally built latest `origin/main` runtime.
Endpoints: Proxy `127.0.0.1:6001`, direct CN1 `127.0.0.1:16001`, and direct CN2 `127.0.0.1:16002`.
Client protocol: MySQL text protocol through the `mysql` CLI and MOTR; SQL `PREPARE` / `EXECUTE` was exercised on the real frontend path.
Compatibility reference: MySQL `8.3.0` in a temporary localhost-only Docker container.
What Was Covered
OK — The original ordinary-aggregate reproduction for `VARCHAR`, `DATE`, and `DATETIME` completed without the prior binding error for `VAR_POP`, `VAR_SAMP`, `STDDEV_POP`, or `STDDEV_SAMP`.
OK — `VARCHAR` results matched MySQL `8.3.0`: `VAR_POP=0.6666666666666666`, `VAR_SAMP=1`, `STDDEV_POP=0.816496580927726`, and `STDDEV_SAMP=1`.
OK — Happy paths cover all four functions plus `VARIANCE`, `STD`, and `STDDEV` aliases on numeric strings.
OK — Temporal coercion covers `DATE`, `TIME`, `DATETIME`, and `TIMESTAMP`.
OK — Window aggregation covers running `VAR_POP` on `VARCHAR` and `STDDEV_SAMP` on `DATETIME`.
OK — SQL `PREPARE` / `EXECUTE` covers string `VAR_POP` and timestamp `STDDEV_SAMP`.
OK — Boundary and unhappy paths cover empty input, `NULL`-only input, a singleton, and a non-numeric string; no binding failure occurred and the numeric-conversion results match MySQL.
OK — Native `INT` remains a control equivalent to numeric-string input.
OK — The recorded MOTR case was replayed through Proxy `6001`, CN1 `16001`, and CN2 `16002`.
Not covered — MySQL binary prepared-statement protocol (`COM_STMT_PREPARE` / `COM_STMT_EXECUTE`) was not added because the issue is resolved at SQL function binding and the SQL `PREPARE` / `EXECUTE` frontend path directly exercises that contract.
Not covered — No additional client drivers or server versions beyond MySQL `8.3.0` were used.
Findings
The previous binding-time rejection of MySQL numeric-convertible string and temporal operands is resolved in the latest `main`. Ordinary aggregates, windows, and SQL prepared execution now reach the numeric-coercion path.
MySQL `8.3.0` comparison matched all stable assertions. For the selected large `DATETIME` / `TIMESTAMP` `VAR_POP` input, MatrixOne and MySQL differ only in an insignificant final floating-point display digit before rounding (`...666624` versus `...666600` at `DECIMAL(24,6)`); the MOTR temporal `VAR_POP` assertion is therefore stabilized at `DECIMAL(24,3)`, while exact deterministic window assertions retain `6` decimals. This is not the original binding/coercion failure.
No MatrixOne service source was modified.
MOTR / BVT Coverage
Added `suites/14_issue_regression/t/issue_28229_variance_coercion.test` and `suites/14_issue_regression/r/issue_28229_variance_coercion.result`.
Recording through Proxy `6001`: `21/21` statements passed.
Normal replay through Proxy `6001`: `21/21` statements passed.
Repeated replay through Proxy `6001`: `42/42` statements passed.
Direct replay through CN1 `16001`: `21/21` statements passed.
Direct replay through CN2 `16002`: `21/21` statements passed.
Daily aggregation: cherry-picked as `9682687f9abaffe410d2e85a1e0d699fc265532b` into MOTR PR #160. No issue-specific PR was created.
Final Conclusion
Fixed. The original MySQL-compatibility binding regression is fixed and the regression coverage is recorded, replayed, pushed, and included in the designated daily MOTR PR.
A large-data regression is not required: this is deterministic per-value binding and coercion behavior, independent of row count, block/batch boundaries, memory or spill state, concurrency, skew, network transfer, and resource scale.
Follow-up precision compatibility issue filed: #28852.\n\n#28229 remains fixed for the original binding/coercion regression; #28852 tracks the observable DATETIME / TIMESTAMPVAR_POP difference from MySQL 8.3.0 after CAST(... AS DECIMAL(24,6)).
Activity
fix: coerce temporal and string variance operands (#28509)
jiangxinmeng1 commentedon Sep 14, 2026
fixed by #28509
slyunnn commentedon Sep 14, 2026
Regression and extended verification for #28229 (2026-09-14)
Verification Environment
What Was Covered
Findings
The previous binding-time rejection of MySQL numeric-convertible string and temporal operands is resolved in the latest `main`. Ordinary aggregates, windows, and SQL prepared execution now reach the numeric-coercion path.
MySQL `8.3.0` comparison matched all stable assertions. For the selected large `DATETIME` / `TIMESTAMP` `VAR_POP` input, MatrixOne and MySQL differ only in an insignificant final floating-point display digit before rounding (`...666624` versus `...666600` at `DECIMAL(24,6)`); the MOTR temporal `VAR_POP` assertion is therefore stabilized at `DECIMAL(24,3)`, while exact deterministic window assertions retain `6` decimals. This is not the original binding/coercion failure.
No MatrixOne service source was modified.
MOTR / BVT Coverage
Added `suites/14_issue_regression/t/issue_28229_variance_coercion.test` and `suites/14_issue_regression/r/issue_28229_variance_coercion.result`.
Final Conclusion
Fixed. The original MySQL-compatibility binding regression is fixed and the regression coverage is recorded, replayed, pushed, and included in the designated daily MOTR PR.
A large-data regression is not required: this is deterministic per-value binding and coercion behavior, independent of row count, block/batch boundaries, memory or spill state, concurrency, skew, network transfer, and resource scale.
slyunnn commentedon Sep 14, 2026
Follow-up precision compatibility issue filed: #28852.\n\n#28229 remains fixed for the original binding/coercion regression; #28852 tracks the observable
DATETIME/TIMESTAMPVAR_POPdifference from MySQL8.3.0afterCAST(... AS DECIMAL(24,6)).fix: coerce temporal and string variance operands (matrixorigin#28509)
fix: coerce temporal and string variance operands (matrixorigin#28509)
fix: coerce temporal and string variance operands (matrixorigin#28509)