ShivamSharma43 opened a new pull request, #2490: URL: https://github.com/apache/iceberg-go/pull/2490
When the parent snapshot's summary had no `total-*` property, or had one that didn't parse as a number, the new snapshot still got a total that started from 0. For example, appending one file to a table whose current summary has only `operation` wrote `total-data-files=1`, no matter how many files the table really has. Later commits then built on that wrong total. ### Cause `updateTotals` in `updateSnapshotSummaries` read the previous total with `previous.GetInt64(totalProp, 0)`. A missing or unparseable value became 0, so a total was always written. ### Fix `updateTotals` now writes a total only when the previous total is present, parses, and is non-negative. Otherwise the total is unknown and is left out. This matches Java's [`SnapshotProducer.updateTotal`](https://github.com/apache/iceberg/blob/52fc764127402ade8170b1b53ddd95fde13cb75c/core/src/main/java/org/apache/iceberg/SnapshotProducer.java#L938-L970) and PyIceberg's `update_snapshot_summaries`. Nothing changes when there is no previous summary (`previous == nil`). Every total still starts at 0, as it does for a table's first snapshot. That includes a parent snapshot with a nil summary, which `TestSummary_ParentSnapshotWithoutSummary` pins to the zero baseline. ### Testing - `TestUpdateSnapshotSummariesOmitsUnknownTotals`: the parent has only `total-records`. The result has `total-records` updated and none of the other five totals. - `TestUpdateSnapshotSummariesOmitsInvalidTotals`: an unparseable and a negative previous total are both left out. - Both new tests fail on main. The existing `TestMergeSnapshotSummaries` cases (no parent, and a parent with all totals) pass unchanged. - `go test ./table/...` passes except for `TestWriteMapType`, two `TestRewriteDataFiles_PartialProgress*` tests and `TestGetReferencedFiles_OverwriteThenExpireExcludesTombstones`. These fail on my Windows machine (the rewrite tests compare `/` and `\` paths), and they fail in exactly the same way on unmodified main. `go vet` and `golangci-lint run ./table/` (v2.14.0) are clean. Closes #2489 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
