Skip to content

[Bug]: GROUP_CONCAT uses non-SQL scientific notation for FLOAT and DOUBLE #28660

Closed

Description

@Ariznawlll

Description

GROUP_CONCAT formats FLOAT and DOUBLE arguments with Go's default float notation instead of MatrixOne's SQL text conversion. Values that direct SELECT and CAST(... AS CHAR) render in fixed or uppercase-exponent form are changed to lowercase scientific notation inside the aggregate.

Environment

  • Branch: main
  • Commit: e7d46d6dfb27696211ca828c55e245d3bd1b634d
  • Deployment: local standalone (1 CN / 1 TN / 1 LogService)
  • Oracle: MySQL 8.3.0, isolated local instance

Steps to reproduce

drop database if exists gc_float_conversion;
create database gc_float_conversion;
use gc_float_conversion;

create table src (id int primary key, f float, d double);
insert into src values
  (1, 0.0000001, 0.0000001),
  (2, 100000000000000000000, 100000000000000000000),
  (3, 1.234567, 1.23456789012345),
  (4, -0.0, -0.0),
  (5, -123456.75, -123456.789012345);

select id, f, cast(f as char), d, cast(d as char) from src order by id;

select group_concat(f order by id separator '|') as direct_f,
       group_concat(cast(f as char) order by id separator '|') as cast_f
from src;

select group_concat(d order by id separator '|') as direct_d,
       group_concat(cast(d as char) order by id separator '|') as cast_d
from src;

Actual behavior

MatrixOne returns:

direct_f = 1e-07|1e+20|1.234567|-0|-123456.75
cast_f   = 0.0000001|1E+20|1.234567|-0|-123456.75

direct_d = 1e-07|1e+20|1.23456789012345|-0|-123456.789012345
cast_d   = 0.0000001|1E+20|1.23456789012345|-0|-123456.789012345

The aggregate changes the string representation of values 1 and 2 even though the explicit SQL conversion does not.

Expected behavior

Direct numeric arguments to GROUP_CONCAT should use the same canonical SQL text conversion as CAST(value AS CHAR). MySQL 8.3.0 produces identical direct-aggregate and explicit-cast strings for both FLOAT and DOUBLE.

Stability and controls

  • Reproducer: 3/3 for FLOAT and DOUBLE.
  • Conversion control: direct SELECT and CAST(... AS CHAR) agree in MatrixOne for the affected values.
  • Ordinary-value control: 1.234567, negative finite values, and the declared FLOAT/DOUBLE storage values remain readable.
  • MySQL 8.3.0 oracle: direct and explicit-cast aggregates are identical in 3/3 runs.
  • Failure atomicity: all probes are read-only and leave the source rows unchanged.

Evidence

All three MatrixOne output files are byte-identical, and all three MySQL output files are byte-identical. Representative values are included above.

Code analysis

pkg/sql/colexec/aggexec/agg_payload.go::writeGroupConcatData decodes the binary float and passes it directly to fmt.Fprint:

case types.T_float32:
    return writeValue(*util.UnsafeFromBytes[float32](data))
case types.T_float64:
    return writeValue(*util.UnsafeFromBytes[float64](data))

Go's default float formatting is not MatrixOne's SQL display conversion. The aggregate should reuse the canonical scale/notation conversion used by CAST and result serialization.

Regression coverage

After the fix, add aggregate-executor and SQL cases spanning fixed/scientific thresholds, positive and negative values, FLOAT/DOUBLE, grouped/ordered execution, and direct-vs-explicit-cast equality.

Related

Activity

  1. added this to the MO-202609 milestone on Sep 11, 2026
  2. added
    kind/bug
    on Sep 11, 2026
  3. added theissue type on Sep 11, 2026
  4. assigned and unassigned on Sep 12, 2026
  5. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:07b25969bfea9d4b76d3bf05d5b0497e4f36eba0
    • 部署:本地独立 1 CN / 1 TN / 1 LogService;每轮均重新启动服务后执行。
    • 执行:每项 SQL 回归连续 3 轮,输出逐轮一致。

    原问题验证

    • GROUP_CONCAT 对 FLOAT/DOUBLE 的科学计数法输出符合 SQL 文本格式。

    Happy Path 覆盖

    • 覆盖 0.0000001、1E+20、常规小数和负零的拼接输出。

    Unhappy Path 覆盖

    • 覆盖极小值、极大值与负零,不出现非 SQL 形式的内部表示。

    白盒验证

    • 以 MOTR 精确文本结果回归。

    回归测试

    测试证据

    • 以上结果均在该 main commit 的独立环境获得;每轮无 stderr,三轮结果一致。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions