Skip to content

refactor!: use the standard library uuid on Go 1.27 and later - #2766

Merged
laskoviymishka merged 5 commits into
apache:mainfrom
laskoviymishka:factory/uuid-build-tag
Dec 2, 2026
Merged

laskoviymishka merged 5 commits into
apache:mainfrom
laskoviymishka:factory/uuid-build-tag

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

This splits internal/uuid by Go version: uuid_google.go keeps the current google/uuid code behind //go:build !go1.27, and uuid_std.go exposes the same names on the standard library uuid package behind //go:build go1.27. On Go 1.27 and later iceberg.UUID is the standard type, and github.com/google/uuid is imported by one file. arrow-go still uses google/uuid in its UUID array, builder and variant APIs, so the places that cross that boundary now convert explicitly, with two small helpers in internal/uuid/convert.go (PassTo and FromArray). Without them the 1.27 build fails and UUID variants stop casting.

Checked with go build ./..., go vet ./... and go test ./... on Go 1.27.4 and on 1.26.8, so both files are built and tested. The existing UUID literal, variant and arrow round-trip tests cover the conversions on 1.27.

On Go 1.27 the standard type has no Version, Variant, MarshalBinary, URN or Time methods. Callers holding a google/uuid value convert it with iceberg.UUID(v). This is noted in the release notes.

Part of #2062.

AI-assisted, reviewed by a human.

Switch table, view, udf, catalog and cmd, tests included, from
github.com/google/uuid to internal/uuid. internal/uuid/uuid.go is now
the only file in the module that imports google/uuid.

Call sites use only the API that google/uuid and the Go 1.27 standard
library uuid package share. uuid.Nil becomes the zero value
uuid.UUID{}, NewRandom and Must(NewRandom()) become New, NewString
becomes New().String(), and the Version/Variant check on the REST
idempotency key becomes the equivalent tests on bytes 6 and 8.
internal/uuid gains NewV7 for the idempotency key. In tests, NewMD5
values become fixed MustParse literals and the metadata file location
tests check the shape of the path instead of pinning the random source
with SetRand.

No behavior change. iceberg.UUID, internal/uuid.UUID and google/uuid's
UUID are the same type through aliases, so no exported signature
changes.

Signed-off-by: laskoviymishka <[email protected]>
Split internal/uuid by Go version. uuid_google.go keeps today's
github.com/google/uuid code behind //go:build !go1.27, and uuid_std.go
provides the same names on the standard library uuid package behind
//go:build go1.27. On Go 1.27 and later iceberg.UUID is therefore the
standard uuid.UUID, and github.com/google/uuid is imported by a single
file.

arrow-go still names google/uuid in its UUID array, builder and variant
APIs, so the sites that cross that boundary convert explicitly instead
of relying on the two types being identical. The untagged convert.go
adds PassTo, which hands a UUID to a function taking another 16-byte
UUID type (variant Builder.AppendUUID), and FromArray, which converts
the value held by a variant back to UUID. UUID builders use
AppendBytes, and UUIDArray values are converted with iceberg.UUID(...).
Without this, the Go 1.27 build fails in variant_bounds.go and
variant_residual.go, and UUID variants fail to cast or panic.

Behavior is unchanged on both Go versions. Tests that passed arrow-go
UUID values or google/uuid-typed builders get the same conversions.

On Go 1.27 and later, exported APIs that use iceberg.UUID take the
standard library type, which lacks google/uuid methods such as Version,
Variant, MarshalBinary, URN and Time. Callers convert a google/uuid
value with iceberg.UUID(v).

Signed-off-by: laskoviymishka <[email protected]>
@laskoviymishka
laskoviymishka marked this pull request as ready for review November 30, 2026 05:21

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! This is the swap we planned. I built and vetted with both go1.27.1 (uuid_std.go) and go1.26.8 (uuid_google.go), and the UUID/variant/literal tests in the root, table and table/internal pass on both. The places where UUIDs cross into arrow-go (AppendBytes, iceberg.UUID(arr.Value(...)), PassTo, FromArray) look complete.

This stacks on #2764 and conflicts with main right now, so it'll need a rebase once #2764 lands. A few nits inline.

Comment thread internal/uuid/convert.go Resolved
Comment thread internal/uuid/uuid_std.go Resolved
Comment thread internal/uuid/convert.go Resolved
FromArray returns UUID values directly, the package comment moves to doc.go,
and uuid_test.go covers FromBytes, NewV7 and FromArray on both builds.

Signed-off-by: laskoviymishka <[email protected]>
@laskoviymishka
laskoviymishka merged commit a62d635 into apache:main Dec 2, 2026
16 checks passed
AynSiddiqui added a commit to AynSiddiqui/iceberg-go that referenced this pull request Dec 2, 2026
Follows apache#2766, which moved every google/uuid import behind internal/uuid.

Signed-off-by: Ayaan <[email protected]>
AynSiddiqui added a commit to AynSiddiqui/iceberg-go that referenced this pull request Dec 2, 2026
Follows apache#2766, which moved every google/uuid import behind internal/uuid.

Signed-off-by: Ayaan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants