feat(table): add RewriteManifests clustering - #1940
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
The clustering and cleanup paths otherwise look good, and the focused race tests, full table subtree, vet, benchmarks, CI, and synthetic merge all passed. One public-API panic remains in cluster-key validation.
| } | ||
|
|
||
| typ := reflect.TypeOf(key) | ||
| if !typ.Comparable() { |
There was a problem hiding this comment.
[P1] Reject cluster keys that cannot safely round-trip through the writer map
reflect.Type.Comparable() only checks the static type. For example, struct{ Value any }{Value: []int{1}} passes this check and then writers[key] panics with hash of unhashable type: []int. A math.NaN() key also passes, but because it is not equal to itself the inserted writer cannot be retrieved during finalization, causing a nil-pointer panic at line 205. I reproduced both through the exported Transaction.RewriteManifests API; NaN is a realistic value when clustering by an identity float partition. Please validate the value itself (for example, reflect.Value.Comparable() plus a reflexivity check) and add public-API regressions for both cases.
61eccdc to
864eff4
Compare
What changed
WithRewriteManifestClusterByfor opt-in clusteringWhy
RewriteManifests.clusterByAPI uses the same idea: keep files with the same key together.Benchmark
Rewrite throughput was roughly neutral in the benchmark. The important result is the read-side benchmark. It exercises
Scan.filterManifestsWithSchema, the manifest-pruning stage used by localPlanFiles.Command:
go test ./table -run=^$ -bench=^BenchmarkManifestPruningModes$ -benchmem -benchtime=1s -count=3Workload: 512 one-entry input manifests, 32 partition values, and an equality filter on
id = 7.That is about 40% lower pruning time, 35% fewer bytes, and 44% fewer allocations for this partition-aligned workload.
Java reference: https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/RewriteManifests.java
Tests
go test ./table/...go vet ./table/...go test -race ./table -run 'TestRewriteManifests(ClusterBy|CleansOrphansOnInvalidClusterKey)' -count=1