Skip to content

Add --purge option to drop table CLI - #3718

Open
jx2lee wants to merge 3 commits into
apache:mainfrom
jx2lee:jx2lee/purge-flags-cli
Open

Add --purge option to drop table CLI#3718
jx2lee wants to merge 3 commits into
apache:mainfrom
jx2lee:jx2lee/purge-flags-cli

Conversation

@jx2lee

@jx2lee jx2lee commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

PyIceberg already exposes Catalog.purge_table, but the CLI only supports dropping a table through catalog.drop_table.

This adds a --purge option to pyiceberg drop table so users can request the existing catalog purge behavior from the CLI. The default behavior remains unchanged: without --purge, the command still calls catalog.drop_table.

Are these changes tested?

Yes.

  • make test PYTEST_ARGS="tests/cli/test_console.py -v -k 'drop_table'"
  • uv run prek run ruff --files pyiceberg/cli/console.py tests/cli/test_console.py
  • uv run prek run ruff-format --files pyiceberg/cli/console.py tests/cli/ test_console.py

Are there any user-facing changes?

Yes. pyiceberg drop table <identifier> --purge is now available and calls catalog.purge_table(identifier).

@jx2lee
jx2lee marked this pull request as ready for review July 28, 2026 13:33

@jayceslesar jayceslesar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it make more sense for this to be its own CLI command instead of a flag? Doesn't make a huge difference to me but I think the option you have here more closely aligns with Java DDL

Comment thread pyiceberg/cli/console.py

@drop.command()
@click.argument("identifier")
@click.option("--purge", is_flag=True, help="Physically delete all table files.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we update cli.md? If not, PyIceberg users might not be aware of this option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ebyhr Good point ! Added short example to cli.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.

3 participants