ShivamSharma43 opened a new pull request, #2470: URL: https://github.com/apache/iceberg-go/pull/2470
Replacing a view with a definition it already had, such as reverting to an earlier query, failed with `invalid view metadata: duplicate version-id 1`. Applying an `add-view-version` update whose content matches an existing version failed the same way. ### Cause `addVersion` uses `reuseOrCreateNewVersionID` to find the matching version and reuse its ID. It then returned early only if that version was added by an update in the current builder. A version that came from the base metadata was appended again, and `Build` rejected the duplicate ID. ### Fix `addVersion` now returns the existing ID for any version that is already known, which is what Java's `ViewMetadata.Builder.addVersionInternal` does. As in Java, `lastAddedVersionID` is set only when the version was added in this builder and is cleared otherwise. So `SetCurrentVersion` produces a single `set-current-view-version` update with the real version ID, and no `add-view-version` update. ### Testing - New `TestAddVersion_ReuseVersionFromBase` builds metadata with v1 and v2, then calls `SetCurrentVersion` on a builder from that base with a new version that has v1's content. It checks that the versions are still `[v1, v2]`, that v1 is current, and that the only change is `set-current-view-version` 1. It fails on main. - `go test ./view/... ./udf/...` passes. `go vet` and `golangci-lint run ./view/...` (v2.15.0) are clean. In `./catalog/...`, the glue, hadoop, hive and sql packages have failures on my Windows machine because of file path handling. They fail in exactly the same way on unmodified main. Closes #2469 🤖 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]
