Skip to content

[Compatibility]: MIN and MAX reject JSON operands accepted by MySQL #28869

Closed as not planned

Description

@Ariznawlll

Description

MatrixOne rejects JSON operands for MIN and MAX, while MySQL defines these aggregates for JSON values using JSON comparison/ordering semantics.

Environment

Reproduction

create table t(id int, j json);
insert into t values
 (1,'null'),(2,'false'),(3,'true'),(4,'1'),(5,'"a"'),(6,null);

select min(j), max(j) from t;
select id, min(j) over(order by id rows unbounded preceding) from t order by id;

MatrixOne behavior

invalid argument aggregate function min, bad value [JSON]

MAX and the window forms are rejected by the same type check. The behavior reproduced in 3/3 fresh runs.

Controls

  • ORDER BY j and GROUP BY j already execute through typed JSON comparison/key paths;
  • GROUP_CONCAT(j ORDER BY id) accepts the same JSON column;
  • explicit string casting allows MIN/MAX to execute, although string order is only a control and is not a replacement for typed JSON order.

Expected behavior

MIN(JSON) and MAX(JSON) should be accepted and use the same JSON value ordering contract as the engine's typed JSON comparison/sort implementation. Ordinary, grouped/window, View, and CTAS paths should resolve consistently.

Code-path analysis

MinMaxSupportedTypes in pkg/sql/plan/function/list_agg.go excludes types.T_json, although JSON is already supported by key comparison and canonical grouping code. The failure occurs before the executor can apply an ordering rule.

Suggested regression coverage

  • JSON null, boolean, number, string, SQL NULL, arrays, and objects;
  • ordinary/grouped/window MIN/MAX, DOP 1/>1, partial/final, spill, View, and CTAS;
  • consistency with ORDER BY and documented behavior for nonscalar values.

Duplicate search

Open and closed issues were searched for JSON MIN/MAX, JSON standard aggregates, JSON ordering, and [JSON] binding errors; no matching report was found.

Activity

  1. added this to the MO-202609 milestone on Sep 14, 2026
  2. added theissue type on Sep 14, 2026
  3. added
    severity/s1
    and removed on Sep 15, 2026
  4. Ariznawlll commented on Oct 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    JSON null versus SQL NULL comparison (2026-10-14)

    A mixed-type grouped check confirms the ordering distinction in MySQL 8.0.46:

    CREATE TEMPORARY TABLE t(g INT, j JSON);
    INSERT INTO t VALUES (1,'null'),(1,'1'),(1,'2'),(1,'"a"'),(1,NULL),(2,NULL);
    SELECT g, MIN(j), JSON_TYPE(MIN(j)), MIN(j) IS NULL,
           MAX(j), JSON_TYPE(MAX(j)), MAX(j) IS NULL
    FROM t GROUP BY g ORDER BY g;

    For group 1, MySQL returns JSON null for MIN(j) (MIN(j) IS NULL = 0) and JSON string "a" for MAX(j); group 2, containing only SQL NULL, returns SQL NULL for both. MO rejects MIN(j) at binding with invalid argument aggregate function min, bad value [JSON].

    The same local runtime also rejects MAX(JSON); its aggregate binder source is unchanged in current origin/main a53390c57de48ac280249ff0e88831e502e20fb0 relative to the tested runtime commit 2ce4e58af6f03b943ee288ffad81012766cf830a.

  5. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Post-merge QA checkpoint (2026-10-22)

    PR #28950 merged at head 3b3dc91df675c8925ac83a4789cd1b78357d4dfb, merge commit 4ffaa4ceaef74f7c7272d454b7ed4412ce9a1e62. The JSON MIN/MAX fix and its focused regression coverage are present in the merged change.

    Pre-merge validation is reported in the PR body: five canonical SQL cases passed twice, six owning packages passed vet, and the latest formal approval is for 529abda180ac0312649bbf04d52fe6a1a20f7b88. The merge only synchronized main after that candidate; the production/test changes were reported unchanged. These are author/reviewer receipts, not tests I independently ran.

    For the exact merge commit, GitHub returned no workflow runs and a pending commit status with zero status checks. The PR head has a successful Iceberg Connector E2E run, unrelated to this change. This environment has no MatrixOne checkout or Go runtime, so I could not run post-merge tests or live SQL.

    The PR explicitly supports full-shutdown upgrades with all nodes on the same release and excludes mixed-version rollout. An older unresolved inline review asks for a different-version remote-partial/stale-destination topology; that behavior is outside the declared PR contract and is not treated as a blocker for this issue. The PR also records a separate strict-metadata diagnostic failure; it remains undiagnosed.

    The behavior fix is merged and has pre-merge test/reviewer evidence. I kept this issue open and added Ariznawlll for post-merge verification, preserving existing assignee VioletQwQ-0.

    Next: tester to run the issue's ordinary, grouped/window, and applicable spill/partial-final JSON MIN/MAX regressions against the merged commit in MatrixOne, then confirm the result here.

  6. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    Consolidated into #28868. The canonical issue now includes this MIN/MAX behavior and the typed JSON ordering acceptance cases, while keeping them distinct from numeric SUM/AVG/VAR/STDDEV coercion. No shared immediate root cause or fix is claimed.

  7. added
    duplicate
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilityduplicatekind/bugseverity/s1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions