deepdave98 opened a new pull request, #4319:
URL: https://github.com/apache/iceberg-python/pull/4319
Closes #4187
# Rationale for this change
`ManageSnapshots.create_branch` and `create_tag` set the ref without
checking whether the name exists, so an existing branch was reset to the given
snapshot and lost its commits, and an existing tag moved. `remove_branch` and
`remove_tag` checked nothing either: a missing name was accepted, a tag could
be removed as a branch, and `remove_branch("main")` left the table reading as
empty.
The names are now checked against the refs as they stand after earlier
operations in the same chain (`_effective_refs`), and the error messages match
Java's `UpdateSnapshotReferencesOperation`: `Ref x already exists`, `Cannot
remove main branch`, `Branch does not exist: x`, `Tag does not exist: x`, `Ref
x is a tag not a branch`, `Ref x is a branch not a tag`. Replacing a ref on
purpose is still possible with `remove_branch(...).create_branch(...)` in one
chain.
AI assistance was used for the analysis and drafting; the change was
reviewed and tested by the author.
## Are these changes tested?
Four unit tests in `tests/table/test_manage_snapshots.py`: an existing name
is refused for both kinds, a name staged earlier in the same chain is refused,
every `remove_*` refusal, and remove-then-create of the same name in one chain
still commits both updates in order. The script from the issue now raises `Ref
dev already exists` and `Ref v1 already exists`, and `dev` keeps `[1, 2]`.
`make lint` and `make test` pass.
## Are there any user-facing changes?
Yes. Calls that silently replaced or removed a ref now raise `ValueError`.
This needs the changelog label.
--
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]