Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked open and closed issues.
The old closed locale issue #10152 does not describe this current, locale-specific grouping defect. The current open FORMAT issues cover rounding and numeric-string conversion rather than locale grouping.
Branch Name
main
Commit ID
f0c31cd4b830be32442cf329e0a3fb08aa9c16c3
Other Environment Information
- Local standalone MatrixOne built from the commit above
- Reference: MySQL 8.3.0
Actual Behavior
FORMAT(..., locale) applies western three-digit grouping to en_IN, ta_IN, and te_IN:
SELECT FORMAT(123456789.12, 2, 'en_IN'),
FORMAT(123456789.12, 2, 'ta_IN'),
FORMAT(123456789.12, 2, 'te_IN');MatrixOne:
123,456,789.12 | 123,456,789.12 | 123,456,789.12
MySQL 8.3:
12,34,56,789.12 | 12,34,56,789.12 | 12,34,56,789.12
The same difference occurs for negative numbers, locale names stored in a VARCHAR column, SQL PREPARE parameters, and CTAS materialization. Every form was executed three times.
Expected Behavior
For these three locales, FORMAT() should apply the locale's Indian grouping pattern: the lowest group has three digits and preceding groups have two digits.
Steps to Reproduce
SELECT FORMAT(123456789.12, 2, 'en_IN');
SELECT FORMAT(-123456789.12, 2, 'ta_IN');
SELECT FORMAT(123456789.12, 2, 'te_IN');
CREATE DATABASE codex_format_locale;
USE codex_format_locale;
CREATE TABLE src(id INT PRIMARY KEY, n DECIMAL(20,2), loc VARCHAR(10));
INSERT INTO src VALUES
(1, 123456789.12, 'en_IN'),
(2, 123456789.12, 'ta_IN'),
(3, 123456789.12, 'te_IN');
SELECT id, loc, FORMAT(n, 2, loc) FROM src ORDER BY id;
PREPARE p FROM 'SELECT FORMAT(?, 2, ?)';
SET @n = 123456789.12, @loc = 'en_IN';
EXECUTE p USING @n, @loc;
DEALLOCATE PREPARE p;
CREATE TABLE dst AS SELECT id, loc, FORMAT(n, 2, loc) f FROM src;
SELECT * FROM dst ORDER BY id;Controls
en_US, de_DE, gu_IN, and hi_IN match MySQL for the same value. The bg_BG reference output contains NUL separator bytes in this MySQL 8.3 build, so it is intentionally excluded from this issue rather than treating an ambiguous MySQL locale artifact as a MatrixOne defect.
Root Cause
pkg/vectorize/format/format.go maps en_IN, ta_IN, and te_IN directly to formatENUS, whose grouping routine always emits groups of three digits. There is no locale implementation for a final three-digit group preceded by repeated two-digit groups.
Activity
Ariznawlll commentedon Sep 9, 2026
补充全量 locale 结果:从
pkg/vectorize/format/format.go枚举出当前注册的全部 110 个 locale,使用FORMAT(123456789.12, 2, locale)和负数控制逐一与 MySQL 8.3 比较。en_IN、ta_IN、te_IN,正负数均稳定复现;bg_BG是唯一额外差异:该 MySQL 8.3 build 返回 NUL (00) 作为分组分隔字节,而 MatrixOne 返回空格 (20)。这更像 MySQL locale 数据的异常/歧义,因此没有将它纳入本 issue 的修复范围。全量比较连续执行完成,证据包含每个 locale 的 HEX 结果,版本仍为
main@f0c31cd4b830be32442cf329e0a3fb08aa9c16c3。fix(sql): harden FORMAT numeric and locale handling (#28508)
Ariznawlll commentedon Sep 10, 2026
测试版本
mainfc621e3616d229c7a29d0c80e73ed8eb1997459c1 Log / 1 TN / 1 CN原问题验证
en_IN、负数ta_IN、te_IN的FORMAT(123456789.12,2,locale)连续 3 次返回 Indian3-2-2分组:12,34,56,789.12 / -12,34,56,789.12 / 12,34,56,789.12。Happy Path 覆盖
PREPARE/EXECUTE与 CTAS 物化路径均保持 Indian 分组。en_US控制组保持西方三位分组123,456,789.12。Unhappy Path 覆盖
本 issue 的接受条件仅定义受支持 locale 的分组;未将未定义 locale fallback 当作本 issue 的错误路径。所有执行后 CTAS 与源表均可读取,未出现异常中断。
白盒验证
修复 PR matrixone#28508 已合入;
pkg/vectorize/format定向单测通过。回归测试
已加入 MOTR PR #153:
issue_28213_28475_28476_28478_28480_format_compatibility.test,连续 3 次通过。测试证据
fc621e3616。测试结论
测试通过。
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)