Skip to content

feat: add core COW rewrite primitive#2752

Open
u70b3 wants to merge 1 commit into
apache:mainfrom
u70b3:feat/core-cow-rewrite-primitive
Open

feat: add core COW rewrite primitive#2752
u70b3 wants to merge 1 commit into
apache:mainfrom
u70b3:feat/core-cow-rewrite-primitive

Conversation

@u70b3

@u70b3 u70b3 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add iceberg::cow_rewrite with candidate planning, batch rewriter trait, replacement writer, orchestration builder, result stats, public API snapshot, and docs.
  • Reuse existing scan pruning/delete application while clearing the rewrite scan predicate so candidate files are read fully.
  • Cover DELETE-style, UPDATE-style, no-op, full-file delete, no-match delete, writer edge cases, delete-file planning, and multi-file replacement path uniqueness.

Core Design

  • Split COW into planning, batch rewriting, and replacement file writing so SQL planning and metadata commit can stay outside the primitive.
  • Plan candidates through the existing scan path to keep manifest pruning and delete-file application consistent with normal reads, then clear only the row predicate for full-file rewrite input.
  • Return removed, added, and unchanged DataFile sets plus stats; callers can pass these to a future overwrite/row-delta action.
  • Write replacement files with unique COW prefixes and preserve the partition values of each source file; this primitive does not repartition rewritten rows.

Related Work Map

flowchart LR
    Read["#2367 / #2414 / #2532<br/>delete-read improvements"] --> Scan["existing scan/read path<br/>visible rows"]
    Scan --> ThisPR["#2752<br/>COW rewrite primitive<br/>plan + rewrite + write files"]
    ThisPR --> Files["removed DataFiles<br/>added DataFiles<br/>stats"]
    Files --> Overwrite["#2185<br/>OverwriteAction<br/>preferred COW commit path"]
    Files --> RowDelta["#2203 / #2678<br/>RowDelta / MoR path"]
    Validator["#2590<br/>SnapshotValidator"] -. future commit validation .-> Overwrite
    Validator -. future commit validation .-> RowDelta
Loading

Notes

Test Plan

  • cargo fmt --all -- --check
  • make check
  • cargo test -p iceberg cow_rewrite
  • cargo test -p iceberg scan
  • cargo test -p iceberg writer
  • cargo test -p iceberg --doc cow_rewrite
  • cargo public-api -p iceberg --all-features -ss | diff - crates/iceberg/public-api.txt

@u70b3 u70b3 changed the title feat: add core COW rewrite primitive [wip] feat: add core COW rewrite primitive Jul 1, 2026
@u70b3
u70b3 force-pushed the feat/core-cow-rewrite-primitive branch from e6803c1 to d177d34 Compare July 1, 2026 01:42
@u70b3 u70b3 changed the title [wip] feat: add core COW rewrite primitive feat: add core COW rewrite primitive Jul 1, 2026
@u70b3
u70b3 force-pushed the feat/core-cow-rewrite-primitive branch 2 times, most recently from 88eb905 to 4f03d35 Compare July 6, 2026 10:39
@u70b3
u70b3 force-pushed the feat/core-cow-rewrite-primitive branch 4 times, most recently from dcd3474 to db7680c Compare July 16, 2026 05:07
@u70b3
u70b3 force-pushed the feat/core-cow-rewrite-primitive branch 5 times, most recently from 1908b40 to d2ff512 Compare July 18, 2026 01:33
Add a core copy-on-write rewrite primitive that plans candidate data
files, applies a caller-provided RecordBatch rewriter, writes
replacement data files, and returns removed/added/unchanged file sets
for future overwrite-style commit actions.

- Plan candidates through the existing scan path so manifest pruning
  and delete-file application stay consistent with normal reads; the
  row predicate is cleared only for the full-file rewrite input.
- Stream rewritten batches to the replacement writer: buffer only the
  prefix before the first changed batch, then open the writer lazily;
  unchanged files open no writer, fully-deleted files produce no
  replacement.
- Bind the replacement writer and partition key to the planned
  snapshot's schema so rewrites survive schema evolution.
- Build the replacement parquet writer via
  ParquetWriterBuilder::from_table_properties so replacement files
  honor the table's write.parquet.* properties.
- Keep the planner internal; CowRewriteBuilder is the only public
  entry and CowRewriteFile fields sit behind accessors.

Cover delete-style, update-style, no-op, full-file delete, no-match
delete, delete-file planning, writer edge cases, schema evolution, and
multi-source replacement path uniqueness.

Part of apache#2269.

Co-Authored-By: Claude <noreply@anthropic.com>
@u70b3
u70b3 force-pushed the feat/core-cow-rewrite-primitive branch from d2ff512 to 42080dd Compare July 22, 2026 12:02
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