Skip to content

[Compatibility]: MySQL EXPLAIN FORMAT=JSON is unavailable #28301

Done

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

74668fc

Other Environment Information

- MatrixOne was built from the commit above and started locally with etc/launch/launch.toml.
- MySQL comparison version: 8.0.45.
- Every statement was repeated three times with the same result.

Actual Behavior

MatrixOne does not provide the MySQL EXPLAIN FORMAT=JSON interface.

The MySQL syntax is rejected by the MatrixOne parser:

EXPLAIN FORMAT=JSON SELECT * FROM target_t WHERE id=1;

MatrixOne's parenthesized syntax recognizes JSON, but execution rejects it:

EXPLAIN (FORMAT JSON) SELECT * FROM target_t WHERE id=1;
not supported: Unsupport explain format 'json'

The same rejection occurs for a table scan, join, CTE, window query, UPDATE,
and DELETE. Ordinary text EXPLAIN works for the same statements.

The explain formatter contains explicit JSON NYI branches across query and
node formatting, so this is not limited to one plan node.

Expected Behavior

MatrixOne should accept MySQL's EXPLAIN FORMAT=JSON syntax and return a valid
JSON document describing the plan. MySQL 8.0.45 returns JSON plans for every
statement below.

Steps to Reproduce

CREATE DATABASE codex_explain_json_0907;
USE codex_explain_json_0907;

CREATE TABLE target_t(id INT PRIMARY KEY, v INT);
CREATE TABLE source_t(id INT PRIMARY KEY, v INT);
INSERT INTO target_t VALUES(1,10),(2,20),(3,30);
INSERT INTO source_t VALUES(1,101),(2,202),(4,404);

-- MySQL-compatible syntax is rejected by the MatrixOne parser.
EXPLAIN FORMAT=JSON SELECT * FROM target_t WHERE id=1;

-- MatrixOne syntax parses JSON but the formatter rejects it.
EXPLAIN (FORMAT JSON) SELECT * FROM target_t WHERE id=1;
EXPLAIN (FORMAT JSON)
SELECT * FROM target_t t JOIN source_t s ON s.id=t.id;
EXPLAIN (FORMAT JSON)
WITH c AS (SELECT * FROM source_t) SELECT * FROM c WHERE id=1;
EXPLAIN (FORMAT JSON)
SELECT ROW_NUMBER() OVER(ORDER BY id) FROM target_t;
EXPLAIN (FORMAT JSON)
UPDATE target_t SET v=v+1 WHERE id=1;
EXPLAIN (FORMAT JSON)
DELETE FROM target_t WHERE id=1;

-- Control: text format works.
EXPLAIN SELECT * FROM target_t WHERE id=1;
EXPLAIN (FORMAT TEXT) SELECT * FROM target_t WHERE id=1;

Additional information

The JSON formatter paths return explicit NYI errors in
pkg/sql/plan/explain/explain_node.go and
pkg/sql/plan/explain/explain_query.go.

Activity

  1. added this to the MO-202609 milestone on Sep 7, 2026
  2. added
    kind/bug
    on Sep 7, 2026
  3. added theissue type on Sep 7, 2026
  4. added
    severity/s1
    and removed on Sep 16, 2026
  5. XuPeng-SH commented on Oct 13, 2026

    @XuPeng-SH
    Contributor

    PR #30111 corrects the JSON EXPLAIN integration on main and now includes the follow-up metadata omissions found through independent QA.

    Validated revision: f398242b31f97a955fdb0d33ba28f60c708801d5.

    The shared IndexSearchScan formatter compiles against current main metadata. Fulltext/fulltext2 retain search modes, pushed predicates, score ranges and INCLUDE column mapping. IVF retains probe count, bucket expansion and thread settings; JSON and explicit VERBOSE show full details while ordinary text remains compatible. Existing option decoders and one shared hook dispatch own the formatting.

    Local validation passed: owning normal/race191 roots; normal golden optimizer102/102 twice, unchanged fulltext2 covered35/35 and IVF INCLUDE text30/30; incremental vet/lint0 issues; current server build. Actual gpt-6.1-sol/xhigh design and final overall review passed. Remote CI is not claimed green.

    Keep this feature issue open for broader JSON EXPLAIN QA acceptance; the correction does not claim full feature, multi-CN/GPU or Connector/J workload coverage.

  6. Ariznawlll commented on Nov 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    QA 验收通过(main)

    测试版本

    • 被测及开测时官方 main:c255da6778fac39bc53b5b9defaab3b6f945e4d6;关闭前再次解析仍为该 SHA。
    • 独立归档构建,双 CN 真实 MySQL 协议;两个 listener 均通过 SELECT git_version() 核对完整 SHA。

    原生 parser/JSON formatter 回归:38 个 root tests × 3 轮,114/114 PASS

    覆盖 MySQL/括号/引号语法、AST round-trip、ANALYZE 边界、越权 format 拒绝,以及 JSON graph 结构、有限统计值、共享节点去重、表别名、自连接、聚合/窗口、UPDATE 多目标及表达式解析、向量/FULLTEXT 索引、不可达/循环/非法元数据等。无 FAIL、SKIP。

    日志 SHA256:a6a371f93b0d0b540c9ce9214aa33b71cf91e57d58b696a8c943e25d244d3b6d。

    真实双 CN SQL:连续 3/3 PASS

    每轮对原报告六类语句分别验收:table scan、JOIN、CTE、WINDOW、UPDATE、DELETE。每个结果均严格为一行一列,并由客户端实际 JSON decode;同时断言 query_block、matrixone.schema_version=1、steps/nodes/edges 及对应操作符存在,而非只检查 SQL 不报错。

    • 两个 CN 都得到可解析计划;UPDATE/DELETE EXPLAIN 后基表精确行集保持不变。
    • FORMAT=JSON、(FORMAT JSON)、FORMAT='json' 生成完全相同的 JSON 文档。
    • 普通 TEXT EXPLAIN 继续作为健康控制。
    • SQL prepared 重复执行及不同阈值参数均返回正确 JSON 计划。
    • 不支持的 format 以 1064 拒绝,失败后数据不变且 fresh CN 健康查询正常。

    三轮日志 SHA256:4d316480d8910dcba5ed9bac4bc23efe81d22869b89d9dff9501eb2beb846300、08c64d8bd6fb7bdc0011b82be173f0e19a0668ad2de1ba59264874be21f71401、d64df2c9a3484965553805f4bffaccafd59397033c34ed881eaf25f505928f4f。

    MOTR 回归

    双 CN SQL 与 114 项 native gate 已推送到 matrixorigin/motr PR 374,head 972e2fce2daebfae1a0bd72743edda48ef3bc659。评论时该 head 有 13 项 checks 为 queued、daily-42 为 SKIPPED;pending 不作为通过证据。

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions