Skip to content

feat(python): add abort method to TableCommit for write rollback#612

Open
hechao-ustc wants to merge 1 commit into
apache:mainfrom
hechao-ustc:feature/python-binding-commit-abort
Open

feat(python): add abort method to TableCommit for write rollback#612
hechao-ustc wants to merge 1 commit into
apache:mainfrom
hechao-ustc:feature/python-binding-commit-abort

Conversation

@hechao-ustc

Copy link
Copy Markdown
Contributor

Purpose

The Python binding is missing write rollback support. The core Rust TableCommit has an abort() method and the C binding already exposes it via paimon_table_commit_abort, but Python users have no way to clean up data files after a failed write. This PR adds abort() to the Python binding so callers can delete newly written files (data, changelog, index) before a commit is persisted.

Brief change log

  • Extract message collection and validation into collect_and_validate_messages helper, shared by commit() and abort()
  • Add PyTableCommit::abort() — calls through to TableCommit::abort(), best-effort file deletion (storage errors silently ignored)
  • Add 5 unit tests covering the abort lifecycle and all validation paths

Tests

New abort-specific tests in bindings/python/tests/test_write.py:

Test Covers
test_abort_cleans_up_written_data Write → abort → table is empty
test_abort_empty_messages_noop Abort with no messages succeeds
test_abort_non_message_raises_typeerror Non-message input raises TypeError
test_abort_cross_table_messages_raises Messages from a different table rejected (ValueError)
test_abort_different_builder_same_table_raises Messages from a different WriteBuilder rejected (ValueError)

Run with:
cd bindings/python
.venv/bin/maturin develop --release
.venv/bin/python -m pytest tests/test_write.py -v -k abort

API and Format

New method on TableCommit:

table.new_write_builder().new_commit().abort(messages)

  • messages: a sequence of CommitMessage objects returned by prepare_commit()
  • Returns None on success
  • Raises TypeError if messages is not iterable or contains non-CommitMessage items
  • Raises ValueError if messages were prepared for a different table or by a different WriteBuilder
  • Deletion is best-effort — no error is raised for missing files or storage failures
  • Empty messages is a no-op

Documentation

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