Skip to content

feat(transaction): add ExpireSnapshotsAction for snapshot lifecycle management#2146

Open
drbothen wants to merge 1 commit intoapache:mainfrom
drbothen:feat/expire-snapshots-action
Open

feat(transaction): add ExpireSnapshotsAction for snapshot lifecycle management#2146
drbothen wants to merge 1 commit intoapache:mainfrom
drbothen:feat/expire-snapshots-action

Conversation

@drbothen
Copy link

Which issue does this PR close?

What changes are included in this PR?

Adds ExpireSnapshotsAction to the transaction API, enabling removal of old snapshots from table metadata. Key features:

  • Explicit expiry: Expire specific snapshot IDs via expire_snapshot_ids()
  • Age-based expiry: Expire snapshots older than a timestamp via expire_older_than_ms()
  • Safety guarantees: Current snapshot is never expired; retain_last(n) ensures a minimum number of snapshots survive
  • File cleanup utility: find_unreferenced_files() identifies data files, manifests, and manifest lists that are only referenced by expired snapshots and can be safely deleted after commit

The action returns a RemoveSnapshots table update and does NOT delete physical files directly, following the Iceberg principle of metadata-first operations.

Are these changes tested?

Yes — 5 unit tests covering:

  • Current snapshot protection
  • Age-based expiry
  • retain_last enforcement
  • No-op when nothing to expire
  • find_unreferenced_files with carried-forward files

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.

Add ExpireSnapshotsAction for snapshot lifecycle management

1 participant