Feature: Add metadata-only replace API to Table for REPLACE snapshot operations
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 28/100
Direção de pesquisa
Comece por pyiceberg/table/update/snapshot.py e pelas APIs de snapshot existentes de Table e Transaction e, em seguida, compare o comportamento proposto com a interface RewriteFiles do Java. Revise tests/table/test_snapshots.py, especialmente test_invalid_operation(), e adicione cobertura focada para trocas de arquivos, números de sequência e operation=REPLACE. Considera-se concluído quando a substituição somente de metadados funcionar atomicamente com entradas Iterable[DataFile] e evitar a serialização Parquet.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 1.2k
- Forks
- 618
- Merge médio
- 1d 10h
- PRs com merge (30d)
- 71
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/iceberg-python
-
PyArrowFileIO: every small S3 write is a 3-request multipart upload; expose allow_delayed_openAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/iceberg-python#4093 ·
Mantenedores costumam responder em até 1 dia
-
Replace `__slots__ = (field1,field2,...)` with `slots=True`Talvez já em andamento @med9110 assumiu há 2 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
apache/iceberg-python#4086 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
View does not expose metadata_location: RestCatalog.load_view discards it from the server's responseTalvez já em andamento @Soumo-git-hub assumiu há 3 dias. Abertakind:bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
apache/iceberg-python#4073 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/iceberg-python#4010 · 3 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
to_bytes silently rescales a Decimal with a negative scaleTalvez já em andamento @Rodrigo-Palma assumiu há 22 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/iceberg-python#3996 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/iceberg-python
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
topoteretes/cognee#5647 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Sendspin/sendspin-python-cli#291 ·
Mantenedores costumam responder em até 6 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
awslabs/visual-asset-management-system#414 ·
Mantenedores costumam responder em até 1 dia
-
bug v1 v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
modelcontextprotocol/python-sdk#3670 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
aicell-lab/bioengine#232 ·
Mantenedores costumam responder em até 1 dia