badalprasadsingh commented on code in PR #2646:
URL: https://github.com/apache/iceberg-go/pull/2646#discussion_r4628339279


##########
table/update_schema.go:
##########
@@ -1129,12 +1131,19 @@ func (u *UpdateSchema) BuildUpdates() ([]Update, 
[]Requirement, error) {
                        )
                }
 
-               if u.nameMapping != nil {
+               // Keep the table's name mapping in step with the schema, as 
Java's
+               // SchemaUpdate and PyIceberg's UpdateSchema do. Otherwise 
files without
+               // field IDs cannot be resolved for added or renamed columns.
+               nameMapping := u.nameMapping
+               if nameMapping == nil {
+                       nameMapping = meta.NameMapping()

Review Comment:
   this changes what users see: schema updates now rewrite 
`schema.name-mapping.default`, and when a new col reuses a name freed by 
"DeleteColumn" or "RenameColumn" -> older files without field ids show the old 
values in it
   
   better: add an unreleased compatibility note in releases.md



##########
table/update_schema.go:
##########


Review Comment:
   when the mapping is [], ore all entries have empty names (something which is 
allowed by the spec), a rename or delete gets nil from "UpdateNameMapping" -> 
so this writes null
   
   go scans and add-files then fail with invalid 
   'schema.name-mapping.default'
   
   better:
   ```go
   if updatedNameMapping == nil {
        // UpdateNameMapping returns nil when no field keeps a name.
        updatedNameMapping = iceberg.NameMapping{}
   }
   ```
   
   also, add a test for it



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