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]: LOAD DATA double-rounds Decimal256 text longer than 76 digits (DECIMAL(65,64) stores 2e-64 for 1.4999..95e-64) #29883
OS type: Linux (box), single-node mo-service -launch etc/launch/launch.toml built from the commit above
Others: Go 1.27.1
Actual Behavior
When DECIMAL text has more than 76 significant digits, LOAD DATA (CSV and JSONLINE) rounds it twice for a Decimal256 column:
Parse256 rounds at its 76-digit limit;
ParseDecimal256 then rounds again to the column scale.
A carry from step 1 changes the result of step 2. For example, in DECIMAL(65,64) the value 0.<63 zeros>14999999999995 is stored as 2e-64, but the correct result is 1e-64.
path
stored value
INSERT '…' / CAST('…' AS DECIMAL(65,64))
0.000…0001 (correct)
LOAD CSV (also -…, …e0)
0.000…0002 / -0.000…0002
LOAD JSONLINE
0.000…0002 / -0.000…0002
Two more problems in Parse256, same as those fixed for Decimal128 in #29853:
Leading zeros of 0.xxx count toward the 76-digit limit, so 0.<76 digits> loses its last digit.
An exponent after the dropped digits is ignored, because the loop breaks at the limit.
Expected Behavior
The discarded digits should be rounded exactly once, to the column scale, as with exact decimal arithmetic, half away from zero. Leading zeros should not consume precision, and the exponent should be honoured.
Steps to Reproduce
createtablec(id int, d decimal(65,64));
-- /tmp/d256.csv: 1,0.000000000000000000000000000000000000000000000000000000000000000149999999999995
load data infile '/tmp/d256.csv' into table c fields terminated by ',';
select concat('d=', d) from c; -- d=0.0000000000000000000000000000000000000000000000000000000000000002, expected ...0001
The same happens with format='jsonline'.
Additional information
The Decimal128 counterpart is #29841 / PR #29853. A fix with unit tests (including a randomized comparison against exact big.Rat rounding) and a SQL regression case follows.
Activity
fix(types): round Decimal256 text once to the column scale (#29884)
Ariznawlll commentedon Oct 12, 2026
测试版本
main02a2823c2007d5e4fb4ada148e93743df337551a原问题验证
将原报告中超过 76 位的
DECIMAL(65,64)文本(0.000...149999999999995)经普通 INSERT、CSV LOAD、JSONLINE LOAD 写入;三条路径都得到正确的一次舍入结果0.0000000000000000000000000000000000000000000000000000000000000001,而非原先错误的尾数...0002。MOTR compare 模式连续 3 次一致。Happy Path 覆盖
e0指数写法逐值核对;CSV/JSONLINE 与原生 INSERT 的差集均为 0。1e-64定点值相等,比较结果为 1;不经过二进制浮点计算 golden。Unhappy Path 覆盖
not-a-decimal被拒绝(当前错误码 20101),目标表仍为 3 行,随后SELECT 1成功;未将错误码表现扩大解释为该问题的修复范围。白盒验证
本轮仅运行 SQL 黑盒回归;未另跑解析器 UT /
-race。因此不宣称所有高精度字符串均已穷尽。回归测试
已在 MOTR PR #229 增加
issue_29883_decimal256_double_round.test及 golden,本地 compare 3/3 通过;PR 尚待合入。测试证据
测试结论
测试通过。
Ariznawlll commentedon Oct 12, 2026
回归归档:本 issue 在 MatrixOne main
02a2823c2007d5e4fb4ada148e93743df337551a上的原问题、正常与边界/异常路径已有上方详细验证记录,MOTR 对应用例本地 compare 3/3 通过。回归 PR https://github.com/matrixorigin/motr/pull/229 已合入(merge commit0ed4301b164aa42d0affa0dc27e17f7435b7bf04)。据此关闭本 issue;本次关闭未增加先前评论未覆盖的验收范围。测试通过。