JeroenSchmidt opened a new pull request, #3649:
URL: https://github.com/apache/iceberg-python/pull/3649
<!-- Closes #${GITHUB_ISSUE_ID} -->
# Rationale for this change
Adds `ManageSnapshots.fast_forward_branch(from_branch, to_ref)` to advance a
branch to the snapshot referenced by another branch or tag, provided the
current snapshot of `from_branch` is an ancestor of `to_ref`'s snapshot.
The method almost matches the behavior of Apache Iceberg's Java reference
implementation (`SnapshotManager.fastForwardBranch` /
`UpdateSnapshotReferencesOperation.replaceBranch(..., fastForward=true)`)
and, by extension, the Spark `system.fast_forward` stored procedure that
depends on it.
However, while the implementation is very close there is one exception;
```md
Unlike Java's `ManageSnapshots.fastForwardBranch`, this method does not
provide Java-parity for intra-chain semantics.
1) Java maintains a mutable `updatedRefs` map that reflects prior operations
in the same chain, so calling `createBranch` and then
`fastForwardBranch`
on the same ref in one chain observes the freshly-created state.
2) pyiceberg's `ManageSnapshots` accumulates `SetSnapshotRefUpdate` values
without
mutating `table_metadata.refs` between chained calls;
-> The no-op and ancestry checks below operate on committed metadata
only.
-> Callers that need Java-parity behavior should commit between chain
steps.
```
For the sake of scope I left out the changes needed to ensure chain sematic
parity between the java and python.
Would the maintainers like a followup PR or have it included in this PR? My
only worry is that it will increase the complexity of an otherwise
straightforward PR.
## Are these changes tested?
Yes. Both unit tests and integration tests were writen
## Are there any user-facing changes?
Yes. `fast_forward_branch`.
See `mkdocs/docs/api.md` for more details.
<!-- In the case of user-facing changes, please add the changelog label. -->
## Related Issues / Pull Requests
* Related to the closed PR
https://github.com/apache/iceberg-python/pull/2434 (related issue
https://github.com/apache/iceberg-python/issues/2433) ; my PR is only focused
on implementing fast_forward
* Implemented one of the missing features mentioned in
https://github.com/apache/iceberg-python/issues/737 from @sungwy
## LLM Disclosure
PR was written with the assistance of Claude Opus 4.7 (1M context) (effort:
high)
It implemented the majority of the tests I defined. Specifically to assist
with what fixtures to use and how best to write the unit tests in an atomic
fashion appropriate for pyIceberg.
--
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]