Repository navigation
Description
Summary
For a floating-point negative zero, MatrixOne's ABS() preserves the negative sign. This differs from MySQL and changes downstream functions that observe the sign of zero. For example, ATAN2(ABS(-0e0), -1e0) returns -π in MatrixOne but +π in MySQL; a predicate comparing that result to PI() consequently omits a matching row.
Environment
- MatrixOne runtime used for the SQL comparison:
8.0.30-MatrixOne-v1.3.0(local single-CN/TN/LogService environment; the running server binary SHA was unavailable). - Current official
mainchecked ata53390c57de48ac280249ff0e88831e502e20fb0. ItsAbsSignedimplementation still usesif v < 0 { v = -v }, so IEEE negative zero is not normalized. The FLOAT/DOUBLE ABS caller uses this function: - Comparison server: MySQL
8.0.46.
Minimal reproduction
SELECT ABS(-0e0), ATAN2(ABS(-0e0), -1e0),
ATAN2(ABS(-0e0), -1e0) = PI();Observed output, repeated 3/3:
| Server | ABS(-0e0) |
ATAN2(...) |
ATAN2(...) = PI() |
|---|---|---|---|
| MatrixOne | -0 |
-3.141592653589793 |
0 |
| MySQL | 0 |
3.141592653589793 |
1 |
The row-level form also reproduces the result difference:
CREATE TABLE abs_zero_filter(id INT PRIMARY KEY, f DOUBLE);
INSERT INTO abs_zero_filter VALUES (1, -0e0), (2, 0e0), (3, -2.5), (4, 2.5);
SELECT id
FROM abs_zero_filter
WHERE ATAN2(ABS(f), -1e0) = PI()
ORDER BY id;- MatrixOne returns
2. - MySQL returns
1, 2.
This row-filter difference was also reproduced 3/3. Controls WHERE f = 0 and WHERE ABS(f) = 0 return both zero rows on both servers; nonzero ABS()/ATAN2() results match.
Expected behavior
ABS(-0e0) should produce positive zero, as it does in MySQL. Downstream expressions such as ATAN2(ABS(-0e0), -1e0) should therefore produce +π, and the equality predicate with PI() should retain the row.
Scope and related reports
This is a wrong-result bug in the supported floating-point ABS() path, not an unavailable function. Existing signed-zero reports such as #28695 (secondary-index equality) and #28856 (HLL distinct aggregation) concern different execution paths and do not cover ABS() followed by a sign-sensitive math function. No exact duplicate for this function composition was found.
A regression should check the sign of zero at the ABS() boundary and a downstream sign-sensitive function/predicate; no test file was added as part of this report.
Activity
fix: normalize signed zero in ABS (#30168)
Ariznawlll commentedon Oct 15, 2026
测试版本
main17a6200f59e764729e5544908fffd5480ae88279原问题验证
ABS(-0e0)返回正零;本地驱动读取后math.Signbit为 false。ATAN2(ABS(-0e0),-1e0)为正π(误差小于1e-12),与PI()的 SQL 比较为 true。原始路径和 MOTR 定向用例各 3 次通过。Happy Path 覆盖
ATAN2(ABS(0e0),-1e0)=PI()为 true。-0e0与0e0经ABS后均满足过滤条件,按id排序返回准确两行1,2;-2.5和2.5不误入该过滤结果。ABS(-2.5)、ABS(2.5)均为2.5;ABS(NULL)保持 NULL。Unhappy Path 覆盖
不适用:此缺陷针对合法浮点负零的符号及后续计算,不涉及错误输入拒绝或失败回滚。NULL 作为有效边界单独验证。
白盒验证
不适用:公开 SQL 和客户端浮点符号检查已覆盖原现象;未做内部故障注入或
-race。回归测试
test/distributed/cases/function/func_math_abs.test;其 PR 的 TKE 镜像构建检查失败,相关 BVT job 被跳过。suites/14_issue_regression/t/issue_30152_abs_signed_zero.test,见 motr PR #240。本地 3/3 通过;PR 的 4 项离线检查通过,但尚未合入、集成 MOTR CI 尚未验证。按本次要求先关闭 issue;持续回归正式生效仍待 PR 合入。测试证据
15/15成功、147/147SQL/场景语句成功;本 issue 对应用例 3/3 成功。测试结论
测试通过。