Skip to content

[python] Add 'paimon table explain' CLI command#7896

Open
TheR1sing3un wants to merge 2 commits into
apache:masterfrom
TheR1sing3un:feat/python-cli-explain
Open

[python] Add 'paimon table explain' CLI command#7896
TheR1sing3un wants to merge 2 commits into
apache:masterfrom
TheR1sing3un:feat/python-cli-explain

Conversation

@TheR1sing3un
Copy link
Copy Markdown
Member

What

Add paimon table explain <db.tbl> CLI subcommand exposing ReadBuilder.explain() (#7869). Supports --where, --select, --limit, --verbose, --format table|json, mirroring paimon table read. Follow-up of #7869 — also removes the CLI TODO left next to ReadBuilder.explain.

Sample output

paimon -c paimon.yaml table explain default.events --where "dt='2026-05-16' AND id=7" --select dt,id,val:

== PyPaimon Scan Plan ==
Table:              default.events (PK, HASH_FIXED)
Snapshot:           5  (schema 0)
Predicate:          (dt = '2026-05-16') AND (id = 7)
Projection:         [dt, id, val]
Partition pruning:  20 -> 4  (pruned 16)
Bucket pruning:     4 -> 1  (pruned 3)
File skipping:      1 -> 1  (pruned 0)
...

--format json is also available for scripting (with level_histogram keys as JSON strings).

Tests

pypaimon/tests/cli_table_test.py adds 7 cases: baseline, --select+--limit, --verbose, partition pruning via --where, JSON format, invalid table, invalid WHERE. Full pypaimon CLI + explain suite is clean locally.

Docs

  • docs/content/pypaimon/cli.md — new ### Table Explain section
  • docs/content/pypaimon/python-api.md — CLI block under existing "Explain Scan Plan" subsection

Generative AI usage

Drafted with the help of Claude Code; reviewed and tested locally by the author.

Surface ReadBuilder.explain() through the CLI so users can inspect a
scan plan without writing Python. Supports --where / --select / --limit
/ --verbose / --format table|json, mirroring 'table read'. Unlike
'table read', --limit is always pushed down (the point of explain is
to reveal what the planner sees, including limit pushdown).

Removes the follow-up TODO next to ReadBuilder.explain. Docs go to
cli.md and python-api.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant