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>
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>
|
@Fokko review when you can? |
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.