Repository navigation
Support atomic multi-table commits through the REST catalog - #4123
Draft
kotwal-itpro wants to merge 1 commit into
Draft
kotwal-itpro wants to merge 1 commit into
kotwal-itpro wants to merge 1 commit into
Conversation
Add Catalog.commit_transactions(*transactions), which commits the staged changes of several table transactions in one request to the REST catalog's transactions/commit endpoint: either every table is updated, or none of them. Each table is refreshed after a successful commit. Other catalogs raise NotImplementedError. A transaction can be given only once, each table at most once, and creating a table is not supported. Conflicts are not retried. On a definite failure (409, 404) the files written for the transactions are deleted; on an unknown outcome (500, 502, 504) they are kept, as in commit_transaction. The endpoint is assumed supported by servers that don't list their endpoints, as in the Java client. Closes apache#4095 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ZBQVsXRmKT8WXDr2qSfbd
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4095
Rationale for this change
The REST spec's
POST /v1/{prefix}/transactions/commitapplies changes to several tables in one atomic operation, and the Java client exposes it asRESTCatalog.commitTransaction(...). PyIceberg had no way to call it, so write-audit-publish across tables or a backfill of related tables couldn't be published atomically from Python.This adds
Catalog.commit_transactions(*transactions):What it does
CommitTransactionRequest, adding the sameAssertTableUUIDthatcommit_transactionadds. The endpoint returns 204, so each table is refreshed afterwards and the transactions are cleared.CatalograisesNotImplementedError, so they can add support later.commit_table: 409 →CommitFailedException, 404 →NoSuchTableError, 500/502/504 →CommitStateUnknownException.commit_transactionfollows. A failed transaction can't be reused.CreateTableTransaction. Transactions without staged changes are skipped, and a call with only empty ones sends nothing.transactions/commitis assumed supported, as in the Java client'sDEFAULT_ENDPOINTS.Not in this PR (open questions)
assert-create) could come later.Catalog.commit_transactions(*transactions)as proposed in Support atomic multi-table commits through the REST catalog (transactions/commit) #4095. Glad to change it, for example to a context manager.Are these changes tested?
tests/catalog/test_rest.py: 12 tests with a mocked server. They cover the request body, the prefix, each error status, file cleanup only when nothing was applied, skipping empty transactions, the input checks and an unsupported endpoint.tests/catalog/test_base.py: the base catalog raisesNotImplementedError.tests/integration/test_rest_catalog.py, against theapache/iceberg-rest-fixturewith S3-compatible storage:CommitFailedException, and neither table gets the staged rows.make test: 4273 passed.make lintpasses on the changed files.Are there any user-facing changes?
Yes: the new
Catalog.commit_transactionsmethod, and a "Multi-table commits" section inmkdocs/docs/api.md.I used an AI coding assistant while writing this change; I reviewed and tested all of it.
🤖 Generated with Claude Code
https://claude.ai/code/session_011ZBQVsXRmKT8WXDr2qSfbd