Skip to content

[Feature Request]: Add managed file exploration to the Python SDK #30048

Closed
1 of 2 issues completed
Closed

Description

@dengn

Is there an existing issue for the same feature request?

  • Checked existing issues for Python SDK file exploration and Parquet support.

Is your feature request related to a problem?

Users exploring Parquet, CSV, or JSON Lines data currently need to infer a schema, hand-write external-table DDL, assemble multi-file projections, and reclaim catalog objects themselves. A notebook workflow needs a relation that can be queried before importing the data, while retaining MatrixOne SQL execution and access controls.

Describe the feature you'd like

Provide optional synchronous Python SDK APIs client.analytics.read_parquet, read_csv, and read_json that return a managed file relation.

Requirements:

  1. Infer supported scalar schemas or accept an explicit schema, and reject unsupported or potentially lossy mappings.
  2. Resolve bounded local file lists/globs; support explicit remote paths through an Arrow filesystem and corresponding MatrixOne stage:// paths.
  3. Support strict schema matching, union_by_name with nullable missing columns, and string-valued Hive partitions.
  4. Allow SQL aggregates/filters through the relation without first importing files. Expose a checked relation SQL expression and bounded Arrow results.
  5. Provide a transactional append into an existing table with strict conversion and primary-key checks through COMMIT.
  6. Reclaim only relation-owned external tables on normal exit and failures; preserve primary failures and document crash recovery.
  7. Detect missing sources, observed schema drift and malformed CSV records before scanning. Make the lack of an immutable source snapshot explicit.
  8. Preserve existing SDK behavior when the analytics extra is not installed.

Describe implementation you've considered

A Python relation layer reuses MatrixOne native external tables, one per source file, and a UNION ALL projection. Schema discovery is performed client-side with optional PyArrow; MatrixOne performs SQL scanning and aggregation. This issue's acceptance scope is that SDK implementation. Native SQL read_parquet() table functions, remote glob discovery and file-snapshot guarantees are separate future work.

Acceptance criteria

  • Query each supported format and obtain the same complete values/aggregates as an independent DuckDB oracle under the documented format conventions.
  • Missing/unsupported/corrupt sources, unsafe schema promotion and precision loss fail explicitly.
  • Tests cover many-file inputs, local S3-compatible sources, privileges, concurrent relations and cross-CN visibility.
  • Import failures leave no partial append; normal cleanup leaves no owned external tables or checked-out connections.
  • API documentation, design documents and reproducible adversarial tests accompany the implementation.

Documentation, Adoption, Use Case, Migration Strategy

with client.analytics.read_parquet('/shared/orders/*.parquet', union_by_name=True) as files:
    with files.query('SELECT count(*) AS n FROM ' + files.sql + ' AS f') as batches:
        for batch in batches:
            print(batch.to_pydict())

Install the optional analytics extra. Source files must be visible to both schema inference and the CN; remote credentials and stages remain caller-managed. No changes to existing load_data APIs are required.

Additional information

The implementation was locally validated on MatrixOne source commit cd8d5abf9665a97d13e50b04840fb74b877fd339, including two CN processes on one host and a local S3 emulator. These are not production-cloud, cross-host or published-release certifications. The implementation PR will contain the exact test matrix and limitations.

Sub-features

Implementation PR

#30054 — draft implementation for design review, with the four sub-feature design documents, executable tests and recorded local evidence.

The parent feature remains open for acceptance; the PR closes its implementation sub-features on merge.

Activity

  1. added a commit that references this issue on Oct 30, 2026
    bbfe556
  2. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    QA handoff for merged #31774 (main bbfe55669a1440424914d45a283a1d0e36f722fa): please verify the public SDK contract and failure/recovery controls for Add managed file exploration to the Python SDK. This isolated QA run inspected the issue and source but did not run functional tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. Author-reported PR validation is separate evidence, not a result of this QA run.

  3. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    Collaborator

    测试补充

    SDK:官方 main d39d8a40343ccd40bf665036388df7a40ee867f8,版本 0.1.16。真实服务使用 #31774 CI 构建,服务端 SHA db8b7b096aa67aa5922d8aef78c78b68baada983,并非该 SDK main SHA 的完整服务端二进制。

    • 覆盖 Parquet/CSV/JSONL schema 推断、DuckDB 对照、多文件 union 和 Hive 分区、文件缺失/漂移、严格导入、权限、同机双 CN 可见性、关系所有权和异常清理。
    • Python 3.9 / Arrow 18.0、Python 3.10 / Arrow 18.1 两组 Analytics 各 307/307 通过、无跳过;每组含 206 项真实服务和 101 项离线或模型检查。129 原生 Linux 同机双 CN 的主键冲突、网络故障、异步 read/load/commit 超时共 12 场景各 10 轮,120/120 通过。
    • 客户端 SIGKILL 持有外表的场景执行 1 轮:记录实际遗留对象,重新连接后按确切 UUID 定向回收;不声称有自动崩溃回收或多轮跨主机覆盖。[Subtask]: Design and implement file schema inference, multi-file relations and Hive partitions #30050 的文件推断子项已关闭。
    • 资源边界:129 原生 8 线程、30 秒预热加 300 秒测量完成 11,900 次操作,errors=0、连接借用/Arrow 活跃内存/pinned bytes 和自有表残留为 0,FD 峰值 13;RSS 从约 303 MiB 增至峰值 557 MiB,超过原脚本的 64 MiB 增长门槛。随后同负载 SDK 和直接 PyMySQL 各 2,640 次对照中,活跃分配稳定约 26–27 MiB,回收分配器空闲块后 RSS 回到约 140 MiB 起点;未确认持续资源泄漏。原始门槛结果仍保留,不能称原压力脚本通过;原文包含该门槛的 [Subtask]: Design and implement file-relation ownership, strict import and recovery semantics #30051 仍开放,继续跟踪。

    后续跟踪与边界

    按功能收尾处理关闭本 issue;上述仍开放的独立问题及未通过的测试门槛保持原状态,继续按关联 issue 跟踪。

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions