Skip to content

[python] Introduce table import, drop and alter to Python CLI#7360

Merged
JingsongLi merged 4 commits intoapache:masterfrom
JingsongLi:cli_import
Mar 8, 2026
Merged

[python] Introduce table import, drop and alter to Python CLI#7360
JingsongLi merged 4 commits intoapache:masterfrom
JingsongLi:cli_import

Conversation

@JingsongLi
Copy link
Contributor

@JingsongLi JingsongLi commented Mar 8, 2026

Purpose

This PR extends the PyPaimon CLI with three new table sub-commands: import, drop, and alter, significantly expanding the CLI's data management capabilities beyond the existing read, get, and create commands.

  • table import — Bulk-load data from CSV or JSON files into an existing Paimon table. Reads the file into a pandas DataFrame, converts it to a PyArrow Table matching the target schema, and writes it using the batch write API.

  • table drop — Drop a table from the catalog with an optional --ignore-if-not-exists (-i) flag. Implemented in both FileSystemCatalog (deletes the table directory) and the abstract Catalog interface.

  • table alter — A rich set of schema alteration sub-commands:

    • set-option / remove-option — Manage table-level key-value options
    • add-column — Add a column with optional --comment, --first, or --after positioning
    • drop-column — Remove a column by name
    • rename-column — Rename an existing column
    • alter-column — Change a column's type, comment, or position (supports combining multiple changes in one command)
    • update-comment — Update the table-level comment

Tests

API and Format

Documentation

Generative AI tooling

Claude-4.6

@JingsongLi JingsongLi changed the title [python] Introduce table import and alter to Python CLI [python] Introduce table import, drop and alter to Python CLI Mar 8, 2026

# Commit write
table_commit.commit(table_write.prepare_commit())
table_write.close()
Copy link
Member

Choose a reason for hiding this comment

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

It's better to close table_write and table_commit in a finally block to ensure resources are always released.

help='Table identifier in format: database.table'
)
alter_parser.add_argument(
'--ignore-if-not-exists',
Copy link
Member

Choose a reason for hiding this comment

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

--ignore-if-not-exists for table alter doesn't have a -i short option, any particular reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, just because I changed the AI model to claude-4.6.

@plusplusjiajia
Copy link
Member

+1

@JingsongLi JingsongLi merged commit 5f5986d into apache:master Mar 8, 2026
6 of 10 checks passed
jerry-024 added a commit to jerry-024/paimon that referenced this pull request Mar 10, 2026
* upstream/master: (31 commits)
  [python] Correct pyroaring version in requirements
  [test] Enrich table name in MergeIntoTableTestBase
  [test] Fix unstable test: FileStoreLookupFunctionTest.testLookupScanLeak
  [python] Remove useless parameters in blob_writer.py
  [rest] Introduce reset consumer api in rest (apache#7372)
  [python] Introduce Python CLI table snapshot (apache#7373)
  [python] Fix time mapping by always using time32 (apache#7371)
  [python] Introduce catalog list-dbs in Python CLI (apache#7366)
  [hotfix][docs] replace the documentation URL for data-types blob (apache#7370)
  [python] Add i short name to ignore-if-not-exists for database
  [python] Support dynamic bucket write (apache#7363)
  [python] Introduce database related commands to Python CLI (apache#7362)
  [python] Introduce table import, drop and alter to Python CLI (apache#7360)
  [python] Fix py version required in README (apache#7361)
  [test] Add missing LeafFunction coverage in PredicateJsonSerdeTest (apache#7359)
  [python] support predicate NotBetween, Like function (apache#7352)
  [python] Introduce Paimon CLI in PyPaimon (apache#7358)
  [doc] Document ignoreIfExists for create_branch
  [core] Add IF NOT EXISTS support for create_branch operation (apache#7353)
  [python] Remove oss and pylance from requirements deps
  ...
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