Skip to content

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

Merged
JingsongLi merged 1 commit into
apache:masterfrom
TheR1sing3un:feat/python-cli-explain
May 20, 2026
Merged

[python] Add 'paimon table explain' CLI command#7896
JingsongLi merged 1 commit 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.

Copy link
Copy Markdown
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi
Copy link
Copy Markdown
Contributor

@TheR1sing3un Please rebase master.

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.
@TheR1sing3un TheR1sing3un force-pushed the feat/python-cli-explain branch from bbc2ed5 to a88e0f1 Compare May 20, 2026 09:37
@TheR1sing3un
Copy link
Copy Markdown
Member Author

@TheR1sing3un Please rebase master.

done~

@JingsongLi JingsongLi merged commit ab395c1 into apache:master May 20, 2026
7 checks passed
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.

2 participants