You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ryanworl (via GitHub)" <gi...@apache.org> on 2026/08/13 20:19:48 UTC
[PR] fix(table): do not emit add-sort-order for an existing sort order id [iceberg-go]
ryanworl opened a new pull request, #1831:
URL: https://github.com/apache/iceberg-go/pull/1831
## What
REST catalogs reject commits that add a sort order under an id that already exists. `MetadataBuilder.AddSortOrder` still emitted `add-sort-order` when the order being "added" was already present in the **base** metadata: the existing guard (`*lastAddedSortOrderID != newOrderID`) only suppresses a second add within the same builder, and a fresh builder starts with `lastAddedSortOrderID == nil`, so the first reuse emitted the update.
`SetDefaultSortOrderID` compounded this by encoding `-1` ("last added") even when no `add-sort-order` preceded it in the update list, so replaying the emitted updates against a fresh builder could not resolve the default.
- The reuse path now records the id as `lastAddedSortOrderID` and returns without appending `add-sort-order`.
- `SetDefaultSortOrderID` encodes `-1` only when the update list actually carries an `add-sort-order` for that id; otherwise it writes the concrete id.
Net effect: setting the default sort order back to an existing order (e.g. unsorted) produces a commit payload with `set-default-sort-order` carrying the concrete id and no `add-sort-order`.
## Tests
- `TestAddSortOrderDoesNotAddDuplicateUpdate` updated: reuse of a base order emits nothing; adding a *new* order twice in one builder still emits exactly one add.
- New `TestAddSortOrderReuseDoesNotDuplicateUpdate`: unsorted→A→unsorted and A→B→A; replaying the emitted updates against a fresh builder reproduces the default.
- `go test ./table/...` and `golangci-lint run` are clean.
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(table): do not emit add-sort-order for an existing sort order id [iceberg-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #1831:
URL: https://github.com/apache/iceberg-go/pull/1831
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org