Feature: Add metadata-only replace API to Table for REPLACE snapshot operations
まだ誰も着手していません。
評価
調査の方向性
pyiceberg/table/update/snapshot.py と既存の Table および Transaction の snapshot API から始め、提案された動作を Java の RewriteFiles インターフェースと比較してください。tests/table/test_snapshots.py、特に test_invalid_operation() を確認し、ファイルの入れ替え、シーケンス番号、operation=REPLACE に対する集中的なカバレッジを追加してください。メタデータのみの置換が Iterable[DataFile] 入力でアトミックに機能し、Parquet のシリアライズを回避できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Feature Request / Improvement
Description
This issue proposes implementing a metadata-only replace API in PyIceberg, enabling orchestrators to submit a set of DataFiles to delete and a set of DataFiles to append in a single atomic transaction.
This functionality is critical for maintenance operations such as data compaction (the "small files" problem), ensuring the logical state of the table remains unaltered while physical data layout is optimized.
Background
In a current PR (#3124, part of #1092), PyIceberg's replace semantics are tightly coupled with PyArrow dataframes (def replace(self, df: pa.Table)). This approach introduces several architectural flaws:
- Coupling Physical Serialization with Metadata: It forces a
.parquetwrite serialization hook directly into the snapshot commit transaction, increasing the risk of schema degradation and blocking network topologies. - Missing
Operation.REPLACE: The current system uses primitives that log asAPPENDorOVERWRITE, muddying the table history and complicating snapshot expiry/maintenance. - Java Inconsistency: This severely drifts from Java Iceberg's native
org.apache.iceberg.RewriteFilesspecification, which strictly isolates the builder into accepting purelyDataFilepointers.
Proposed Solution
To fix this and achieve logical equivalence, we must implement an exact port of Java's RewriteFiles builder API into PyIceberg's native _SnapshotProducer engine.
-
Introduce
_RewriteFilesSnapshot Producer:
Add a new_RewriteFilesclass that specifically targets replacing existing files. This class will implement:_deleted_entries(): To find the existing target files and re-emit them asDELETEDentries, defensively keeping their ancestralsequence_numbers completely intact for time travel compatibility._existing_manifests(): To scavenge unchanged manifests natively, skipping deep rewrites and only mutating manifests impacted by the deleted files.
-
Builder Hook Implementation:
ImplementUpdateSnapshot().replace()which configures the transaction withOperation.REPLACE. -
Expose Shorthands on Table & Transaction:
AddreplaceAPIs on bothTableandTransactiontakingIterable[DataFile]arguments to elegantly wrap the snapshot mutation:def replace( self, files_to_delete: Iterable[DataFile], files_to_add: Iterable[DataFile], snapshot_properties: dict[str, str] = EMPTY_DICT, branch: str | None = MAIN_BRANCH, ) -> None: ...
Notable canges
replace()API implemented on bothTableandTransactionusingIterable[DataFile].- PyArrow
.parquetwrite logic decoupled from the metadata transaction. _RewriteFilescorrectly copies ancestralsequence_numberpointers forDELETEDandEXISTINGmanifest entries.- Snapshots committed via the
replace()hook possess a Summary containingoperation=Operation.REPLACE. - Unit tests pass simulating data file swaps and summary verifications.
Related Java API
Inspired heavily by Java's builder interface: https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/RewriteFiles.java
AI Disclosure
AI was used to help understand the code base and draft code changes. All code changes have been thoroughly reviewed, ensuring that the code changes are in line with a broader understanding of the codebase.
- Worth deeper review after AI-assistance:
- The
test_invalid_operation()intests/table/test_snapshots.pypreviously usedOperation.REPLACEas a value to test invalid operations, but with this changeOperation.REPLACEbecomes valid. In place I just put a dummy Operation. - The
_RewriteFilesinpyiceberg/table/update/snapshot.pyoverrides the_deleted_entriesand_existing_manifestsfunctions. I sought to test this thoroughly that it was done correctly. I am thinking it's possible to improve the test suite to make this more rigorous. I am open to suggestions on how that could be done.
- 主要言語
- Python
- スター
- 1.1k
- フォーク
- 589
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 70
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg-python のほかの issue
-
kind:bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
apache/iceberg-python#4006 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg-python#3996 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/iceberg-python#3979 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg-python#3885 ·
-
[Bug] PyArrowFileIO fails to propagate s3.ssl.ca-cert to pyarrow.fs.S3FileSystem tls_ca_file_path オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/iceberg-python#3866 · コメント 1 件 ·
apache/iceberg-python の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
canonical/paas-charm#368 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
StevenBlack/hosts#3256 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
qualcomm/qai-appbuilder#275 ·