This is an automated email from the ASF dual-hosted git repository.

laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 57ae3f858 Add AssignFreshSchemaIDsWithBase (#2076)
57ae3f858 is described below

commit 57ae3f8589c5e11f3be282221cc40c358f3b16f0
Author: Alex Stephen <[email protected]>
AuthorDate: Thu Oct 1 00:58:48 2026 -0700

    Add AssignFreshSchemaIDsWithBase (#2076)
    
    * feat(schema): add AssignFreshSchemaIDsWithBase
    
    Port Java's TypeUtil.assignFreshIds(schema, baseSchema, nextId). Fields
    whose full column name exists in the base schema reuse its ID; all
    others get fresh IDs from nextID. This lets callers evolve a table
    schema declaratively without reusing retired column IDs, by passing the
    current schema as base and counting up from last-column-id.
    
    AssignFreshSchemaIDs now delegates to the new function with a nil base.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    
    * fix(schema): return errors instead of panicking in 
AssignFreshSchemaIDsWithBase
    
    - Start the default nextID counter after base.HighestFieldID() so fresh
      IDs can't collide with IDs reused from base.
    - Check for duplicate field IDs before building the schema, so a nextID
      that returns IDs that are too low gives an error instead of a panic.
    - Return an error for identifier field IDs that aren't in the schema,
      instead of mapping them to 0.
    - Document the nextID range and case-sensitive name matching.
    - Rename setFreshIDs.visiting to source.
    - Add tests for list<struct>, the nil nextID path, and new and stale
      identifier fields.
    
    * fix(schema): assign sibling field IDs before recursing
    
    Java's AssignFreshIds.struct gives IDs to all fields of a struct before
    visiting their nested types. We handed out IDs depth-first, so nested
    schemas got different IDs than Java (and Rust, per the old TODOs in
    TestReassignIds) would give them.
    
    This changes the IDs AssignFreshSchemaIDs gives new tables with nested
    columns, so the table fixtures that hardcoded the old order are updated.
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 schema.go                               |  50 ++++++-
 schema_test.go                          | 243 ++++++++++++++++++++++++++++++--
 table/metadata_builder_internal_test.go |   8 +-
 table/update_schema_test.go             |  82 +++++------
 4 files changed, 323 insertions(+), 60 deletions(-)

diff --git a/schema.go b/schema.go
index 42501789e..b9170b63a 100644
--- a/schema.go
+++ b/schema.go
@@ -1486,24 +1486,44 @@ func buildAccessors(schema *Schema) (map[int]accessor, 
error) {
 type setFreshIDs struct {
        oldIdToNew map[int]int
        nextIDFunc func() int
+       source     *Schema
+       base       *Schema
 }
 
 func (s *setFreshIDs) getAndInc(currentID int) int {
-       next := s.nextIDFunc()
+       next := s.idFor(currentID)
        s.oldIdToNew[currentID] = next
 
        return next
 }
 
+func (s *setFreshIDs) idFor(currentID int) int {
+       if s.base != nil {
+               if name, ok := s.source.FindColumnName(currentID); ok {
+                       if f, ok := s.base.FindFieldByName(name); ok {
+                               return f.ID
+                       }
+               }
+       }
+
+       return s.nextIDFunc()
+}
+
 func (s *setFreshIDs) Schema(_ *Schema, structResult func() Type) Type {
        return structResult()
 }
 
 func (s *setFreshIDs) Struct(st StructType, fieldResults []func() Type) Type {
+       // Assign all sibling IDs before recursing, matching Java.
+       newIDs := make([]int, len(st.FieldList))
+       for idx, f := range st.FieldList {
+               newIDs[idx] = s.getAndInc(f.ID)
+       }
+
        newFields := make([]NestedField, len(st.FieldList))
        for idx, f := range st.FieldList {
                newFields[idx] = NestedField{
-                       ID:             s.getAndInc(f.ID),
+                       ID:             newIDs[idx],
                        Name:           f.Name,
                        Type:           fieldResults[idx](),
                        Doc:            f.Doc,
@@ -1555,15 +1575,29 @@ func (s *setFreshIDs) Variant(v VariantType) Type {
 // fields in it. The nextID function is used to iteratively generate the ids, 
if
 // it is nil then a simple incrementing counter is used starting at 1.
 func AssignFreshSchemaIDs(sc *Schema, nextID func() int) (*Schema, error) {
+       return AssignFreshSchemaIDsWithBase(sc, nil, nextID)
+}
+
+// AssignFreshSchemaIDsWithBase is like AssignFreshSchemaIDs, but fields whose
+// full name exists in base reuse the ID from base. Only fields not found in
+// base get fresh IDs from nextID. Name matching is case-sensitive.
+//
+// nextID must return IDs greater than base.HighestFieldID(), otherwise an
+// error is returned for the duplicate. If nextID is nil, the counter starts
+// after base's highest field ID.
+func AssignFreshSchemaIDsWithBase(sc, base *Schema, nextID func() int) 
(*Schema, error) {
        if nextID == nil {
                id := 0
+               if base != nil {
+                       id = base.HighestFieldID()
+               }
                nextID = func() int {
                        id++
 
                        return id
                }
        }
-       visitor := &setFreshIDs{oldIdToNew: make(map[int]int), nextIDFunc: 
nextID}
+       visitor := &setFreshIDs{oldIdToNew: make(map[int]int), nextIDFunc: 
nextID, source: sc, base: base}
        outType, err := PreOrderVisit(sc, visitor)
        if err != nil {
                return nil, err
@@ -1574,10 +1608,18 @@ func AssignFreshSchemaIDs(sc *Schema, nextID func() 
int) (*Schema, error) {
        if len(sc.IdentifierFieldIDs) != 0 {
                newIdentifierIDs = make([]int, len(sc.IdentifierFieldIDs))
                for i, id := range sc.IdentifierFieldIDs {
-                       newIdentifierIDs[i] = visitor.oldIdToNew[id]
+                       newID, ok := visitor.oldIdToNew[id]
+                       if !ok {
+                               return nil, fmt.Errorf("%w: cannot find field 
for identifier field id %d", ErrInvalidSchema, id)
+                       }
+                       newIdentifierIDs[i] = newID
                }
        }
 
+       if err := checkDuplicateFieldIDs(nil, fields); err != nil {
+               return nil, err
+       }
+
        return NewSchemaWithIdentifiers(0, newIdentifierIDs, fields...), nil
 }
 
diff --git a/schema_test.go b/schema_test.go
index f0773a188..b35225644 100644
--- a/schema_test.go
+++ b/schema_test.go
@@ -1484,21 +1484,22 @@ func TestAssignFreshSchemaIDs(t *testing.T) {
        require.NoError(t, err)
        require.NotNil(t, sc)
 
+       // Like Java, siblings get IDs before their children are visited.
        startID = 100
-       var checkID func(iceberg.NestedField)
-       checkID = func(f iceberg.NestedField) {
-               startID++
-               assert.Equal(t, startID, f.ID)
-               if nested, ok := f.Type.(iceberg.NestedType); ok {
-                       for _, nf := range nested.Fields() {
-                               checkID(nf)
+       var checkIDs func([]iceberg.NestedField)
+       checkIDs = func(fields []iceberg.NestedField) {
+               for _, f := range fields {
+                       startID++
+                       assert.Equal(t, startID, f.ID)
+               }
+               for _, f := range fields {
+                       if nested, ok := f.Type.(iceberg.NestedType); ok {
+                               checkIDs(nested.Fields())
                        }
                }
        }
 
-       for _, f := range sc.Fields() {
-               checkID(f)
-       }
+       checkIDs(sc.Fields())
 }
 
 func TestAssignFreshSchemaIDsPreservesDefaults(t *testing.T) {
@@ -1573,6 +1574,228 @@ func TestAssignFreshSchemaIDsPreservesDefaults(t 
*testing.T) {
        assert.Nil(t, nestedWithoutDefaults.WriteDefault)
 }
 
+func TestAssignFreshSchemaIDsWithBase(t *testing.T) {
+       // base is the table's current schema. Column 3 ("dropped") has been
+       // removed from the new schema, so last-column-id stays at 9.
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64, Required: true},
+               iceberg.NestedField{ID: 2, Name: "location", Type: 
&iceberg.StructType{
+                       FieldList: []iceberg.NestedField{
+                               {ID: 4, Name: "lat", Type: 
iceberg.PrimitiveTypes.Float64},
+                       },
+               }},
+               iceberg.NestedField{ID: 3, Name: "dropped", Type: 
iceberg.PrimitiveTypes.String},
+               iceberg.NestedField{ID: 5, Name: "tags", Type: 
&iceberg.ListType{
+                       ElementID: 6, Element: iceberg.PrimitiveTypes.String,
+               }},
+               iceberg.NestedField{ID: 7, Name: "props", Type: 
&iceberg.MapType{
+                       KeyID: 8, KeyType: iceberg.PrimitiveTypes.String,
+                       ValueID: 9, ValueType: iceberg.PrimitiveTypes.String,
+               }},
+       )
+
+       // The new schema reorders columns, adds "name" and "location.long", and
+       // uses placeholder IDs that don't match base.
+       sc := iceberg.NewSchemaWithIdentifiers(0, []int{101},
+               iceberg.NestedField{ID: 100, Name: "name", Type: 
iceberg.PrimitiveTypes.String},
+               iceberg.NestedField{ID: 101, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64, Required: true},
+               iceberg.NestedField{ID: 102, Name: "props", Type: 
&iceberg.MapType{
+                       KeyID: 103, KeyType: iceberg.PrimitiveTypes.String,
+                       ValueID: 104, ValueType: iceberg.PrimitiveTypes.String,
+               }},
+               iceberg.NestedField{ID: 105, Name: "tags", Type: 
&iceberg.ListType{
+                       ElementID: 106, Element: iceberg.PrimitiveTypes.String,
+               }},
+               iceberg.NestedField{ID: 107, Name: "location", Type: 
&iceberg.StructType{
+                       FieldList: []iceberg.NestedField{
+                               {ID: 108, Name: "lat", Type: 
iceberg.PrimitiveTypes.Float64},
+                               {ID: 109, Name: "long", Type: 
iceberg.PrimitiveTypes.Float64},
+                       },
+               }},
+       )
+
+       lastColumnID := 9
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, func() int {
+               lastColumnID++
+
+               return lastColumnID
+       })
+       require.NoError(t, err)
+
+       expected := iceberg.NewSchemaWithIdentifiers(0, []int{1},
+               iceberg.NestedField{ID: 10, Name: "name", Type: 
iceberg.PrimitiveTypes.String},
+               iceberg.NestedField{ID: 1, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64, Required: true},
+               iceberg.NestedField{ID: 7, Name: "props", Type: 
&iceberg.MapType{
+                       KeyID: 8, KeyType: iceberg.PrimitiveTypes.String,
+                       ValueID: 9, ValueType: iceberg.PrimitiveTypes.String,
+               }},
+               iceberg.NestedField{ID: 5, Name: "tags", Type: 
&iceberg.ListType{
+                       ElementID: 6, Element: iceberg.PrimitiveTypes.String,
+               }},
+               iceberg.NestedField{ID: 2, Name: "location", Type: 
&iceberg.StructType{
+                       FieldList: []iceberg.NestedField{
+                               {ID: 4, Name: "lat", Type: 
iceberg.PrimitiveTypes.Float64},
+                               {ID: 11, Name: "long", Type: 
iceberg.PrimitiveTypes.Float64},
+                       },
+               }},
+       )
+       assert.True(t, expected.Equals(out), "expected %s, got %s", expected, 
out)
+       assert.Equal(t, []int{1}, out.IdentifierFieldIDs)
+       assert.Equal(t, 11, lastColumnID, "only new fields should consume IDs")
+}
+
+func TestAssignFreshSchemaIDsWithBaseCaseSensitive(t *testing.T) {
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64},
+       )
+       sc := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "ID", Type: 
iceberg.PrimitiveTypes.Int64},
+       )
+
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, func() int { 
return 50 })
+       require.NoError(t, err)
+       assert.Equal(t, 50, out.Field(0).ID)
+}
+
+func TestAssignFreshSchemaIDsSiblingsFirst(t *testing.T) {
+       // location is visited before name, but name should still get the lower
+       // fresh ID because sibling IDs are assigned before recursing.
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "location", Type: 
&iceberg.StructType{
+                       FieldList: []iceberg.NestedField{
+                               {ID: 2, Name: "lat", Type: 
iceberg.PrimitiveTypes.Float64},
+                       },
+               }},
+       )
+       sc := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 100, Name: "location", Type: 
&iceberg.StructType{
+                       FieldList: []iceberg.NestedField{
+                               {ID: 101, Name: "lat", Type: 
iceberg.PrimitiveTypes.Float64},
+                               {ID: 102, Name: "long", Type: 
iceberg.PrimitiveTypes.Float64},
+                       },
+               }},
+               iceberg.NestedField{ID: 103, Name: "name", Type: 
iceberg.PrimitiveTypes.String},
+       )
+
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, nil)
+       require.NoError(t, err)
+
+       name, ok := out.FindFieldByName("name")
+       require.True(t, ok)
+       assert.Equal(t, 3, name.ID)
+       long, ok := out.FindFieldByName("location.long")
+       require.True(t, ok)
+       assert.Equal(t, 4, long.ID)
+}
+
+func TestAssignFreshSchemaIDsWithBaseListOfStruct(t *testing.T) {
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "events", Type: 
&iceberg.ListType{
+                       ElementID: 2,
+                       Element: &iceberg.StructType{FieldList: 
[]iceberg.NestedField{
+                               {ID: 3, Name: "ts", Type: 
iceberg.PrimitiveTypes.TimestampTz},
+                       }},
+               }},
+       )
+       sc := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 100, Name: "events", Type: 
&iceberg.ListType{
+                       ElementID: 101,
+                       Element: &iceberg.StructType{FieldList: 
[]iceberg.NestedField{
+                               {ID: 102, Name: "ts", Type: 
iceberg.PrimitiveTypes.TimestampTz},
+                               {ID: 103, Name: "label", Type: 
iceberg.PrimitiveTypes.String},
+                       }},
+               }},
+       )
+
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, nil)
+       require.NoError(t, err)
+
+       expected := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "events", Type: 
&iceberg.ListType{
+                       ElementID: 2,
+                       Element: &iceberg.StructType{FieldList: 
[]iceberg.NestedField{
+                               {ID: 3, Name: "ts", Type: 
iceberg.PrimitiveTypes.TimestampTz},
+                               {ID: 4, Name: "label", Type: 
iceberg.PrimitiveTypes.String},
+                       }},
+               }},
+       )
+       assert.True(t, expected.Equals(out), "expected %s, got %s", expected, 
out)
+}
+
+func TestAssignFreshSchemaIDsWithBaseNilNextID(t *testing.T) {
+       // The default counter must start above base's IDs, or c would get 1.
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 2, Name: "b", Type: 
iceberg.PrimitiveTypes.Int32},
+       )
+       sc := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "b", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 2, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 3, Name: "c", Type: 
iceberg.PrimitiveTypes.Int32},
+       )
+
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, nil)
+       require.NoError(t, err)
+
+       expected := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 2, Name: "b", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 3, Name: "c", Type: 
iceberg.PrimitiveTypes.Int32},
+       )
+       assert.True(t, expected.Equals(out), "expected %s, got %s", expected, 
out)
+}
+
+func TestAssignFreshSchemaIDsWithBaseNextIDTooLow(t *testing.T) {
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32},
+       )
+       sc := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 2, Name: "b", Type: 
iceberg.PrimitiveTypes.Int32},
+       )
+
+       var out *iceberg.Schema
+       var err error
+       require.NotPanics(t, func() {
+               out, err = iceberg.AssignFreshSchemaIDsWithBase(sc, base, 
func() int { return 1 })
+       })
+       assert.ErrorIs(t, err, iceberg.ErrInvalidSchema)
+       assert.Nil(t, out)
+}
+
+func TestAssignFreshSchemaIDsWithBaseNewIdentifierField(t *testing.T) {
+       base := iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32, Required: true},
+       )
+       sc := iceberg.NewSchemaWithIdentifiers(0, []int{10, 11},
+               iceberg.NestedField{ID: 10, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32, Required: true},
+               iceberg.NestedField{ID: 11, Name: "b", Type: 
iceberg.PrimitiveTypes.Int32, Required: true},
+       )
+
+       out, err := iceberg.AssignFreshSchemaIDsWithBase(sc, base, nil)
+       require.NoError(t, err)
+       assert.Equal(t, []int{1, 2}, out.IdentifierFieldIDs)
+}
+
+func TestAssignFreshSchemaIDsStaleIdentifierField(t *testing.T) {
+       sc := iceberg.NewSchemaWithIdentifiers(0, []int{99},
+               iceberg.NestedField{ID: 1, Name: "a", Type: 
iceberg.PrimitiveTypes.Int32, Required: true},
+       )
+
+       _, err := iceberg.AssignFreshSchemaIDsWithBase(sc, nil, nil)
+       assert.ErrorIs(t, err, iceberg.ErrInvalidSchema)
+}
+
+func TestAssignFreshSchemaIDsWithNilBase(t *testing.T) {
+       withBase, err := 
iceberg.AssignFreshSchemaIDsWithBase(tableSchemaNested, nil, nil)
+       require.NoError(t, err)
+       withoutBase, err := iceberg.AssignFreshSchemaIDs(tableSchemaNested, nil)
+       require.NoError(t, err)
+
+       assert.True(t, withoutBase.Equals(withBase))
+       assert.Equal(t, withoutBase.IdentifierFieldIDs, 
withBase.IdentifierFieldIDs)
+}
+
 func TestSchemaRoundTrip(t *testing.T) {
        data, err := json.Marshal(tableSchemaNested)
        require.NoError(t, err)
diff --git a/table/metadata_builder_internal_test.go 
b/table/metadata_builder_internal_test.go
index b0a881249..cfd6b56f9 100644
--- a/table/metadata_builder_internal_test.go
+++ b/table/metadata_builder_internal_test.go
@@ -269,9 +269,8 @@ func TestReassignIds(t *testing.T) {
                Type: &iceberg.StructType{
                        FieldList: []iceberg.NestedField{
                                {
-                                       Type: iceberg.PrimitiveTypes.Int64,
-                                       // TODO: this is discrepancy with rust 
impl, is 5 over there
-                                       ID:       4,
+                                       Type:     iceberg.PrimitiveTypes.Int64,
+                                       ID:       5,
                                        Name:     "nested",
                                        Required: true,
                                },
@@ -280,8 +279,7 @@ func TestReassignIds(t *testing.T) {
                Required: true,
        },
                iceberg.NestedField{
-                       // TODO: this is discrepancy with rust impl, is 4 over 
there
-                       ID:       5,
+                       ID:       4,
                        Name:     "c",
                        Type:     iceberg.PrimitiveTypes.Int64,
                        Required: true,
diff --git a/table/update_schema_test.go b/table/update_schema_test.go
index 1c9ddf2db..d5e94d00d 100644
--- a/table/update_schema_test.go
+++ b/table/update_schema_test.go
@@ -72,16 +72,16 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -117,16 +117,16 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -159,16 +159,16 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -191,8 +191,8 @@ func TestAddColumn(t *testing.T) {
 
                newSchema, err := NewUpdateSchema(txn, true, 
true).AddColumn([]string{"files"}, &iceberg.StructType{
                        FieldList: []iceberg.NestedField{
-                               {ID: 5, Name: "id", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                               {ID: 6, Name: "name", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 7, Name: "id", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 8, Name: "name", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                        },
                }, "", false, nil).Apply()
                assert.NoError(t, err)
@@ -204,16 +204,16 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -243,17 +243,17 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                        {ID: 12, Name: "code", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -269,8 +269,8 @@ func TestAddColumn(t *testing.T) {
 
                newSchema, err := NewUpdateSchema(txn, true, 
true).AddColumn([]string{"address", "code"}, &iceberg.StructType{
                        FieldList: []iceberg.NestedField{
-                               {ID: 5, Name: "code-1", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                               {ID: 6, Name: "code-2", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 7, Name: "code-1", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 8, Name: "code-2", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                        },
                }, "", false, nil).Apply()
                assert.NoError(t, err)
@@ -282,8 +282,8 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                        {ID: 12, Name: "code", Type: 
&iceberg.StructType{
                                                FieldList: 
[]iceberg.NestedField{
                                                        {ID: 13, Name: 
"code-1", Type: iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
@@ -292,12 +292,12 @@ func TestAddColumn(t *testing.T) {
                                        }, Required: false, Doc: ""},
                                },
                        }},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,
@@ -313,8 +313,8 @@ func TestAddColumn(t *testing.T) {
 
                newSchema, err := NewUpdateSchema(txn, true, 
true).AddColumn([]string{"address", "code"}, &iceberg.StructType{
                        FieldList: []iceberg.NestedField{
-                               {ID: 5, Name: "code-1", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                               {ID: 6, Name: "code-2", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 7, Name: "code-1", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                               {ID: 8, Name: "code-2", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                        },
                }, "", false, nil).AddColumn([]string{"gender"}, 
iceberg.PrimitiveTypes.String, "", false, nil).AddColumn([]string{"files"}, 
&iceberg.ListType{
                        Element:         iceberg.PrimitiveTypes.String,
@@ -329,8 +329,8 @@ func TestAddColumn(t *testing.T) {
                        {ID: 3, Name: "age", Type: 
iceberg.PrimitiveTypes.Int32, Required: false, Doc: ""},
                        {ID: 4, Name: "address", Type: &iceberg.StructType{
                                FieldList: []iceberg.NestedField{
-                                       {ID: 5, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
-                                       {ID: 6, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 7, Name: "city", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
+                                       {ID: 8, Name: "zip", Type: 
iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
                                        {ID: 12, Name: "code", Type: 
&iceberg.StructType{
                                                FieldList: 
[]iceberg.NestedField{
                                                        {ID: 13, Name: 
"code-1", Type: iceberg.PrimitiveTypes.String, Required: false, Doc: ""},
@@ -339,12 +339,12 @@ func TestAddColumn(t *testing.T) {
                                        }, Required: false, Doc: ""},
                                },
                        }, Required: false, Doc: ""},
-                       {ID: 7, Name: "tags", Type: &iceberg.ListType{
-                               ElementID:       8,
+                       {ID: 5, Name: "tags", Type: &iceberg.ListType{
+                               ElementID:       9,
                                Element:         iceberg.PrimitiveTypes.String,
                                ElementRequired: false,
                        }, Required: false, Doc: ""},
-                       {ID: 9, Name: "properties", Type: &iceberg.MapType{
+                       {ID: 6, Name: "properties", Type: &iceberg.MapType{
                                KeyID:         10,
                                KeyType:       iceberg.PrimitiveTypes.String,
                                ValueID:       11,

Reply via email to