zeroshade commented on code in PR #1643:
URL: https://github.com/apache/iceberg-go/pull/1643#discussion_r3732154513


##########
view/updates_test.go:
##########
@@ -131,3 +131,41 @@ func TestUpdatesUnmarshalJSONReplacesExistingSlice(t 
*testing.T) {
        require.NoError(t, json.Unmarshal([]byte(`[]`), &updates))
        assert.Empty(t, updates)
 }
+
+func TestPropertyUpdateConstructorsCopyInputs(t *testing.T) {
+       props := iceberg.Properties{"owner": "alice"}
+       set := NewSetPropertiesUpdate(props)
+       props["owner"] = "bob"
+       props["team"] = "iceberg"
+       assert.Equal(t, iceberg.Properties{"owner": "alice"}, set.Updates)
+
+       removals := []string{"old-property"}
+       remove := NewRemovePropertiesUpdate(removals)
+       removals[0] = "new-property"
+       assert.Equal(t, []string{"old-property"}, remove.Removals)
+}
+
+func TestMetadataBuilderPropertyChangesCopyInputs(t *testing.T) {
+       props := iceberg.Properties{"owner": "alice"}
+       removals := []string{"old-property"}
+
+       base, err := newTestBuilder().
+               SetLoc("location").
+               AddSchema(newTestSchema(0)).
+               AddVersion(newTestVersion(1, 0)).
+               SetCurrentVersionID(1).
+               Build()
+       require.NoError(t, err)
+
+       builder, err := MetadataBuilderFromBase(base)
+       require.NoError(t, err)
+       result, err := 
builder.SetProperties(props).RemoveProperties(removals).Build()

Review Comment:
   Non-blocking: consider separating `SetProperties`/`RemoveProperties` from 
`Build`, mutating `props` and `removals` in between, and only then building. 
That directly exercises the staging interval this fix protects. Explicit nil 
and non-nil-empty cases would also pin the preservation semantics of 
`maps.Clone` and `slices.Clone`.



-- 
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]

Reply via email to