Skip to content

feat: Add Snapshot::into_builder for updating existing snapshots - #3169

Draft
alexanderbianchi wants to merge 1 commit into
apache:mainfrom
alexanderbianchi:snapshot-into-builder
Draft

feat: Add Snapshot::into_builder for updating existing snapshots#3169
alexanderbianchi wants to merge 1 commit into
apache:mainfrom
alexanderbianchi:snapshot-into-builder

Conversation

@alexanderbianchi

Copy link
Copy Markdown

What changes are included in this PR?

Add Snapshot::into_builder() to modify an existing snapshot without manually copying every unchanged field:

let updated = snapshot.into_builder().with_summary(summary).build();

TableMetadata already exposes the same conversion:

let builder = metadata.into_builder(None);

That delegates to TableMetadataBuilder::new_from_metadata(metadata, None). Snapshots currently have only a builder for constructing a new value, so even replacing a summary requires repeating IDs, sequence number, timestamp, manifest location, and other fields.

into_builder() returns a SnapshotUpdateBuilder that owns the existing snapshot and replaces only explicitly set fields. The existing Snapshot::builder() and its compile-time required-field checks are unchanged: its typed builder does not permit overwriting populated fields, so it cannot serve as an editing builder directly. No dependencies or serialization changes.

Motivation

Use case: DataFusion Distributed #700, where fixture tests replace snapshot summaries to exercise missing statistics. This review comment highlights the resulting snapshot-reconstruction boilerplate.

This constructs a snapshot value only; table metadata updates and their snapshot-ID/sequence-number validation remain unchanged.

Are these changes tested?

  • Unit test covers an unchanged round trip, replacing only the summary while preserving all other fields (including encryption and row lineage), field overrides, and clearing optional IDs.
  • cargo test -p iceberg --lib --locked — 1,675 passed.
  • cargo test -p iceberg --doc into_builder --locked — passed.
  • cargo clippy -p iceberg --lib --tests --all-features --locked -- -D warnings — passed.
  • Public API snapshot regenerated with cargo public-api -p iceberg --all-features -ss.
  • cargo fmt --all -- --check and git diff --check — passed.

AI Disclosure

Implementation, tests, and this description were prepared with AI coding assistance.

@alexanderbianchi
alexanderbianchi marked this pull request as draft September 7, 2026 20:21
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