Revanth14 opened a new pull request, #2372:
URL: https://github.com/apache/iceberg-go/pull/2372
## Problem
A schema can hold binary and fixed defaults as `[]byte`, `BinaryLiteral` or
`FixedLiteral`, while the same schema read from metadata holds hex strings. The
byte forms are shared with the caller, so changing the slice after `NewSchema`
changes the schema, and they are why schema reads have to deep-clone defaults.
The two in-memory forms also compare unequal: a schema built with `[]byte`
defaults is not `Equals` to its own metadata round trip, and union-by-name
rewrites an unchanged binary write default.
## Fix
`NewSchemaWithIdentifiers`, which every `NewSchema*` constructor and
`AddColumn` go through, stores these defaults as the hex string used in
metadata JSON, at any depth. It copies only the fields and types on the path to
a rewritten default, so the caller's fields and types are never modified, and a
schema without byte defaults is not copied. `NestedField.MarshalJSON` uses the
same helper. Readers already accept the hex form. Nested `[]any` /
`map[string]any` defaults are unchanged: they only come from metadata, and the
spec limits them to `null` or `{}`.
## Testing
New tests cover each byte form for binary and fixed, nested defaults with
the caller's types left unchanged, isolation from the caller's slice, the JSON
round trip, `AddColumn`, and union-by-name keeping an unchanged binary write
default; all of them fail with the normalization call removed. Three clone
tests that wrote into byte defaults now assert the hex form.
## Context
Step 2 of the deep-immutability series in #2062. Breaking: a binary or fixed
default read from a schema is now a `string`; see the release note.
--
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]