Skip to content

[Feature]: MODUMP should honor file suffix for jsonline/parquet output instead of always writing CSV #30570

Description

@Ariznawlll

Is there an existing issue for this?

  • I have checked the existing issues.

Branch Name

main

Commit ID

b24d1b3 (2026-10-16)

What problem are you trying to solve?

MODUMP QUERY_RESULT '<id>' INTO '<path>' always writes CSV regardless of the output file's extension. export.go already has full support for jsonline and parquet via inferFormatFromSuffix / validateExportFormat, but the MODUMP path never calls them, so ExportFormat stays empty and getExportFormat() falls back to "csv".

Actual behavior

modump query_result '<id>' into '/tmp/out.jsonline';   -- writes CSV
modump query_result '<id>' into '/tmp/out.parquet';    -- writes CSV (magic bytes are "id,n...", not "PAR1")

Both files contain CSV text, despite their extensions.

Proposed solution

Make MODUMP honor the output file suffix the same way SELECT ... INTO does: call inferFormatFromSuffix (and validateExportFormat) in the MODUMP path (e.g. in doDumpQueryResult in pkg/frontend/query_result.go) so .jsonl/.jsonline/.ndjson produce JSON Lines and .parquet produces Parquet.

Additional information

  • Root cause: pkg/frontend/query_result.go (doDumpQueryResult) never sets ExportParam.ExportFormat nor calls validateExportFormat; the format inference logic lives in pkg/frontend/export.go but is only wired into the SELECT ... INTO / EXPORT path.
  • The MODUMP grammar (mo_dump_stmt) has no FORMAT keyword, so suffix-based inference is the natural mechanism to reuse.

Activity

  1. added this to the MO-202610 milestone on Oct 19, 2026
  2. XuPeng-SH commented on Oct 28, 2026

    @XuPeng-SH
    Contributor

    QA on merged main b888c218fb3a4f094bb8417288a45c47402e5635 (#31466): our local parser checks passed (3 top-level tests, 26 RUN entries); resource limits prevented local writer/readback and error-path connection-reuse verification.

    Subsequent independent verification by Ariznawlll on f847803 is documented in #30570 (comment): CSV, three JSON Lines suffixes and Parquet were each exported and read back 3/3; invalid query IDs left no file and the connection recovered. The focused MOTR case passed 3/3; the full MOTR suite was not run. These are the reporter's results, not local results from this QA environment.

    A separate binary-reader interoperability defect remains tracked in #31495: on f847803, the reporter found BINARY/VARBINARY with non-UTF-8 bytes exported as Parquet UTF-8 strings and failed PyArrow readback through both MODUMP and SELECT INTO OUTFILE. BLOB and ASCII controls passed, and MO LOAD recovered the bytes. Do not generalize the suffix verification to all binary Parquet data.

  3. assigned and unassigned on Oct 28, 2026
  4. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 官方 main f847803802289b2b2d0df4f0a2f842c2804b823a,已核对修复 #31466 的 merge commit b888c218fb3a4f094bb8417288a45c47402e5635 在祖先链。
    • 2026-10-28;macOS/arm64,本地隔离 1 CN + 1 TN + 1 Log,运行二进制的 VCS revision 与上述完整 SHA 一致,MySQL 协议;服务和临时文件均为本次独立资源。

    原问题验证

    开启结果保存后执行公开查询,再对同一 query ID 执行 MODUMP。CSV、.jsonl、.jsonline、.ndjson 和 .parquet 各 3 次均成功;直接读取文件内容:CSV 为列名 id,name 和行 7,hello;三种 JSON Lines 均为 {"id":7,"name":"hello"};使用 PyArrow 独立读取 Parquet 得到相同字段和值,确认不是仅凭扩展名或魔数判断。

    Happy Path 覆盖

    上述五种格式各 3/3,源查询返回 (7, hello);导出后临时目录按每轮清理。save_query_result 在本次独立连接设置,不更改全局配置。

    Unhappy Path 覆盖

    无效 query ID 3/3 返回 20440(query id not found),没有创建目标文件;同一连接随后 SELECT 1 返回 1。此次无写表失败原子性场景;未验证无效 UTF-8 和远程对象存储。

    白盒验证

    本轮以 MySQL 协议、真实文件和 PyArrow 读取为黑盒,未新增 Go UT/race;修复 PR 中有格式写出与 Parquet 读回定向 UT。

    回归测试

    MOTR #284 的 issue_30570_modump_formats.py 使用本机文件系统及 PyArrow,显式设置 MOTR_LOCAL_FILE_TESTS=1 后定向 3/3;未配置时标记跳过,不把跳过当通过。未运行完整 MOTR suite。

    测试证据

    修复 PR 的 CI 包含通过与 skipped 项;MOTR 新 head CI 在发布时尚未报告,不能声明完整 CI 通过。本地独立读取、异常和 MOTR 三轮结果如上。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions