alliasgher opened a new pull request, #873:
URL: https://github.com/apache/iceberg-go/pull/873
## Summary
`MetadataBuilder.RemoveSnapshots()` previously pruned the snapshot list,
snapshot log, and refs, but left `StatisticsFile` and `PartitionStatisticsFile`
entries behind even when their `SnapshotID` matched a removed snapshot. This
left stale statistics entries in the table metadata after snapshot expiration.
Fixes #836
## Changes
### `table/metadata.go`
- Add `statisticsList` and `partitionStatsList` fields to `MetadataBuilder`
so the builder can hold them across operations
- Load both lists from the base metadata in `MetadataBuilderFromBase` using
the existing `Statistics()` / `PartitionStatistics()` iterators
- Include both lists when building `commonMetadata` in `buildCommonMetadata`
so they survive a `Build()` round trip
- In `RemoveSnapshots`, `slices.DeleteFunc` the matching entries out of both
lists, mirroring how `snapshotList` and `snapshotLog` are pruned
### `table/metadata_builder_internal_test.go`
- Add `TestRemoveSnapshotsPrunesStatistics` that constructs a metadata with
statistics for two snapshots, removes one, and verifies:
- `MetadataBuilderFromBase` loads both lists from the base
- Only the kept snapshot's statistics remain after `RemoveSnapshots`
- The kept entries survive a `Build()` round trip via `Statistics()` and
`PartitionStatistics()`
## Verification
- `go build ./table/` passes
- `go vet ./table/` passes
- `go test ./table/` passes (new test + all existing tests)
Fixes #836
--
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]