Skip to content

[Bug]: GROUP_CONCAT renders BOOL as false/true instead of SQL 0/1 #28658

Closed

Description

@Ariznawlll

Description

GROUP_CONCAT renders MatrixOne BOOL values as the words false and true, while direct SELECT, CAST(... AS CHAR), CONCAT_WS, CTAS consumers, and MySQL-compatible boolean conversion use 0 and 1.

This changes the value only when BOOL is passed directly to 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_bool_conversion;
create database gc_bool_conversion;
use gc_bool_conversion;

create table src (id int primary key, flag bool);
insert into src values (1, false), (2, true), (3, null);

select id, flag, cast(flag as char), concat_ws('', flag)
from src order by id;

select group_concat(flag order by id separator '|') as direct_gc,
       group_concat(cast(flag as char) order by id separator '|') as cast_gc,
       group_concat(concat_ws('', flag) order by id separator '|') as concat_ws_gc
from src;

The same direct aggregate was also executed through a View, CTAS, and a prepared statement.

Actual behavior

id  flag  cast(flag as char)  concat_ws('', flag)
1   0     0                   0
2   1     1                   1
3   NULL  NULL                ''

direct_gc  = false|true
cast_gc    = 0|1
concat_gc  = 0|1|

CTAS, View, and PreparedStatement consumers all preserve the unexpected false|true text.

Expected behavior

Direct BOOL aggregation should use the same text conversion as direct SELECT and explicit CAST, producing 0|1. MySQL 8.3.0 produces 0|1 for the same table and query.

Stability and controls

  • Reproducer: 3/3 for direct SELECT, CTAS, View, and PreparedStatement paths.
  • Conversion control: CAST(flag AS CHAR) and CONCAT_WS('', flag) produce 0/1 in MatrixOne.
  • NULL control: direct BOOL aggregation skips the NULL row, as expected.
  • MySQL 8.3.0 oracle: direct and explicit-cast aggregates both produce 0|1 in 3/3 runs.
  • Failure atomicity: all aggregate probes are read-only; CTAS materializes the returned text without changing source rows.

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 a BOOL payload and passes the Go bool directly to fmt.Fprint, which emits false/true:

case types.T_bool:
    return writeValue(*util.UnsafeFromBytes[bool](data))

This bypasses MatrixOne's normal SQL boolean-to-string conversion. The aggregate should reuse the canonical SQL text conversion rather than Go's boolean formatter.

Regression coverage

After the fix, add aggregate-executor and SQL regression cases for false, true, and NULL through direct, grouped, ordered, CTAS/View, and prepared execution paths.

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 对 BOOL 输出 SQL 0/1,而非 false/true。

    Happy Path 覆盖

    • 覆盖 true、false 与数值 CAST 对照,输出为 0/1。

    Unhappy Path 覆盖

    • 覆盖 NULL BOOL,聚合按既有 NULL 规则处理且不污染非 NULL 结果。

    白盒验证

    • 以 MOTR 断言 BOOL 与 CAST 输出相等。

    回归测试

    测试证据

    • 以上结果均在该 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