ryanworl opened a new pull request, #1833:
URL: https://github.com/apache/iceberg-go/pull/1833

   ## What
   
   Adds `Transaction.ReplaceSortOrder(order)`: the Go analogue of Java's 
[`Table.replaceSortOrder()`](https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/Table.java)
 / 
[`BaseReplaceSortOrder`](https://github.com/apache/iceberg/blob/master/core/src/main/java/org/apache/iceberg/BaseReplaceSortOrder.java),
 which replaces the table's default write order. It applies `AddSortOrder` + 
`SetDefaultSortOrder(-1)`, and no-ops when the staged default already has 
identical fields (field-only compare — the incoming order's id must not affect 
the result). Java's version is a fluent `asc()`/`desc()` builder; taking a 
complete `SortOrder` is the idiomatic Go adaptation of the same operation.
   
   It also exports `FileToDataFile`, the parquet-footer-to-`DataFile` 
conversion backing `AddFiles`, with a `sortOrderID` parameter. #1184 removed 
that parameter from the internal function so `AddFiles` would not claim 
`sort_order_id` on files it did not write — correct for that caller, but it 
left no way for a caller who *does* know a foreign file's sort layout to convey 
it (data-file field `sort_order_id` in the spec). `AddFiles`/`filesToDataFiles` 
still pass 0, preserving #1184's behavior.
   
   The two ship together because a rewrite/compaction flow uses both: 
`ReplaceSortOrder` installs the table's write order, and `FileToDataFile` 
stamps that order id on the rewritten files it registers.
   
   Behavioral note: re-selecting an order that already exists in base metadata 
should emit only `set-default-sort-order` with the concrete id — that is 
#1831's fix; without it, strict REST catalogs reject the reuse commit's 
`add-sort-order`. The diffs are independent; this PR does not depend on it 
textually.
   
   ## Tests
   
   - Replace unsorted→new order; field-identical replace is a no-op; sequential 
replaces assign fresh ids.
   - `FileToDataFile`: stats round-trip; `sortOrderID` 0 leaves the field 
unset, non-zero is stamped; missing file returns an error.
   - `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: [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]

Reply via email to