Repository navigation
Conversation
Branch writes and current-snapshot moves rebuilt refs without carrying their retention fields, clearing policies that create_branch had set. Preserve the existing ref's max ref age, max snapshot age, and min snapshots to keep on those move paths. Refs without retention stay unset. Signed-off-by: 1fanwang <1fannnw@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Preserves ref retention policies when snapshots move through writes, current-snapshot changes, and rollbacks.
Changes:
- Carries retention fields through ref updates.
- Adds unit and integration regression coverage.
| File | Description |
|---|---|
tests/table/test_manage_snapshots.py |
Adds unit coverage for retention behavior. |
tests/integration/test_writes/test_writes.py |
Adds catalog integration coverage. |
pyiceberg/table/update/snapshot.py |
Preserves retention metadata during snapshot moves. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
…retention-policy Signed-off-by: 1fanwang <1fannnw@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
A ref created with a retention policy (max ref age, max snapshot age and minimum snapshots to keep) loses all three settings once a branch is written to, or once main is moved with set_current_snapshot or rollback_to_snapshot. The ref is rebuilt without them, so the policy a table owner set is silently unset.
Fast-forward already carries the settings over. This change makes branch writes, set_current_snapshot and rollback_to_snapshot do the same, and a ref created without a policy still stays unset. It continues #3770 and is separate from #3760, which expires stale refs.
Are these changes tested?
Yes, with a live reproducer; the commands and observed output are under Testing Done.
Testing Done
The reproducer below uses the public API against a SQLite-backed catalog with a local warehouse. It creates a branch with a policy, writes to it three times, then rolls main back and forward again, printing the policy after each step. A branch created without a policy is the control. The same script runs twice on one checkout: first with the one changed source file taken from origin/main, then with the branch's own file.
Before, with the file from origin/main:
After, with this branch's file:
Only the SQLite-backed SqlCatalog on a local filesystem was exercised.
Reproducer source: repro_ref_retention.py
Are there any user-facing changes?
A ref keeps the retention policy it was created with when its snapshot moves. There is no API change.
AI Disclosure
AI disclosure: GitHub Copilot CLI (GPT-6 Astra and Claude Sonnet 5.5) helped rebase the stale PR, bring it up to date with main, rewrite this description around a live reproducer, and rerun the checks.