This is an automated email from the ASF dual-hosted git repository.
zeroshade 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 41423ee82 fix(table): do not overwrite the caller's path in
UpdateSchema rename (#2333)
41423ee82 is described below
commit 41423ee8275125fa50ab4f1a30d7c6af1864ea8a
Author: jj.lee <[email protected]>
AuthorDate: Tue Oct 27 04:26:23 2026 +0900
fix(table): do not overwrite the caller's path in UpdateSchema rename
(#2333)
Signed-off-by: jx2lee <[email protected]>
---
table/update_schema.go | 2 +-
table/update_schema_test.go | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/table/update_schema.go b/table/update_schema.go
index e4e5c95dd..69ee4951d 100644
--- a/table/update_schema.go
+++ b/table/update_schema.go
@@ -447,7 +447,7 @@ func (u *UpdateSchema) updateColumn(path []string, update
ColumnUpdate) error {
return fmt.Errorf("cannot rename field to the same
name: %s", fullName)
}
- newFullName := strings.Join(append(path[:len(path)-1],
update.Name.Val), ".")
+ newFullName :=
strings.Join(append(slices.Clone(path[:len(path)-1]), update.Name.Val), ".")
if existingField, ok := u.findField(newFullName); ok {
if !u.isDeleted(existingField.ID) {
return fmt.Errorf("field already exists: %s",
newFullName)
diff --git a/table/update_schema_test.go b/table/update_schema_test.go
index d5e94d00d..3d46f97ea 100644
--- a/table/update_schema_test.go
+++ b/table/update_schema_test.go
@@ -2621,3 +2621,19 @@ func TestUnionByNameRejectsOverlappingAdds(t *testing.T)
{
require.Error(t, err, "re-adding a field already pending must be
rejected")
assert.Contains(t, err.Error(), "name")
}
+
+func TestRenameColumnDoesNotMutatePath(t *testing.T) {
+ tbl := New([]string{"id"}, testMetadata, "", nil, nil)
+
+ path := []string{"address", "city"}
+ sc, err := NewUpdateSchema(tbl.NewTransaction(), true, false).
+ RenameColumn(path, "town").
+ UpdateColumn(path, ColumnUpdate{Doc:
iceberg.Optional[string]{Valid: true, Val: "the town"}}).
+ Apply()
+ require.NoError(t, err)
+ assert.Equal(t, []string{"address", "city"}, path)
+
+ f, ok := sc.FindFieldByName("address.town")
+ require.True(t, ok)
+ assert.Equal(t, "the town", f.Doc)
+}