ryanworl opened a new pull request, #1786: URL: https://github.com/apache/iceberg-go/pull/1786
Adds `Transaction.AssertRefSnapshotID(branch)`: the same `assert-ref-snapshot-id` requirement Java's `UpdateRequirements` builds for a changed ref, exposed so metadata-only commits can use it too. A transaction that only sets properties (e.g. exactly-once bookkeeping that records ingestion offsets) can require that the branch is unchanged from the state it read; if another writer committed in between, the commit fails with `ErrCommitFailed` instead of being silently replayed onto the new head. Two commits: 1. **Align ref requirement accumulation with Java.** `UpdateRequirements` accumulates one assertion per ref, built from the base table state. Our producers built theirs from the staged metadata's current snapshot instead — an id the catalog has never seen when a transaction carries multiple operations. Producers, `RollbackToSnapshot`, and `ExpireSnapshots` now assert the base state, and two same-ref assertions requiring different snapshot ids are rejected at apply time rather than one being silently dropped. 2. **Expose the requirement on `Transaction`.** Matches Java semantics: an explicit requirement and a producer-built one for the same branch collapse to one. The one Go-specific wrinkle is the commit retry loop, which rewrites ref assertions to the fresh head between retries; explicitly registered assertions are exempt, since rewriting would void the compare-and-swap the caller asked for. Without this, Go writers have to commit an empty `AddFiles` append per metadata-only write to serialize through a producer's requirement (an included test documents that workaround, which also matches Java's zero-file `newFastAppend().commit()` behavior). Made with [Cursor](https://cursor.com) -- 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]
