ForeverAngry opened a new pull request, #2369:
URL: https://github.com/apache/iceberg-python/pull/2369
GitHub Copilot
# Rationale for this change
Add richer snapshot expiration retention capabilities:
- retain_last_n(n): keep N most recent snapshots regardless of age.
- older_than_with_retention(...): combine max age filter with retain_last_n
and a minimum snapshots floor.
- with_retention_policy(...): unified API that also consumes table property
defaults:
- history.expire.max-snapshot-age-ms
- history.expire.min-snapshots-to-keep
- history.expire.max-ref-age-ms (plumbed for future ref expiration logic)
Internal helpers:
- _get_expiration_properties: parses table properties.
- _get_snapshots_to_expire_with_retention: core selection logic factoring
protected refs (branches/tags), age, recency, and minimum keep guardrail.
Motivation: safer, configurable space reclamation while preventing
accidental over‑expiration.
## Are these changes tested?
Yes. Extended test_expire_snapshots.py with new cases:
- test_retain_last_n_with_protection
- test_older_than_with_retention_combination
- test_with_retention_policy_defaults
- test_get_expiration_properties
- test_get_snapshots_to_expire_with_retention_respects_protection
Tests cover interaction of all parameters, property default fallback,
protection of branch/tag snapshots, and minimum keep enforcement.
## Are there any user-facing changes?
Yes :
- New public methods: retain_last_n, older_than_with_retention,
with_retention_policy on ExpireSnapshots.
- Table properties history.expire.max-snapshot-age-ms and
history.expire.min-snapshots-to-keep now auto-applied by with_retention_policy.
No breaking changes to existing APIs; older_than and by_id/by_ids behavior
unchanged. Documentation/changelog should be updated to reflect new retention
strategy APIs and property usage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]