Skip to content

[Bug]: SUM() over a boolean expression rejected with bad value [BOOL] (MySQL compatibility) #24547

Closed

Description

@dengn

Version: 8.0.30-MatrixOne-v3.0.11 (MatrixOne v3.0.11)

A very common MySQL idiom SUM(<boolean expr>) (count rows matching a condition) fails in MatrixOne.

Reproduce

SELECT SUM(v > 1) FROM (SELECT 0 AS v UNION ALL SELECT 2) t;
-- e.g. SUM(status = 'ERROR') over a spans table

Actual

ERROR 20203 (HY000): invalid argument aggregate function sum, bad value [BOOL]

Expected
MySQL coerces booleans to 0/1, so SUM(boolean_expr) returns the count of true rows. Workaround: SUM(CASE WHEN v > 1 THEN 1 ELSE 0 END).


Found while evaluating MatrixOne git4data / SQL as a data-versioning & agent-trace backend. Version: 8.0.30-MatrixOne-v3.0.11 (MatrixOne v3.0.11).

Testing background

Found while computing per-trace error counts over an OpenTelemetry agent-trace table stored in MatrixOne: the natural rollup is SUM(status = 'ERROR') grouped by trace, to get error counts/rates per agent run.

Why it matters (expected purpose)

We're using MatrixOne as a queryable + versionable agent-trace backend; error-rate rollups via SUM(<bool>) are an extremely common, idiomatic MySQL pattern. Supporting boolean->0/1 coercion in SUM keeps observability queries simple and MySQL-compatible.

Activity

  1. ghost added
    kind/bug
    on May 29, 2026
  2. ghost added theissue type on May 29, 2026
  3. ghost added this to the MO-202605 milestone on May 29, 2026
  4. added a commit that references this issue on Jun 2, 2026
    ece1079
  5. added
    severity/s0
    on Jun 30, 2026
  6. modified the milestones: MO-202605, MO-202607 on Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions