laskoviymishka commented on code in PR #2723:
URL: https://github.com/apache/iceberg-go/pull/2723#discussion_r4718507981


##########
table/update_schema.go:
##########
@@ -402,6 +402,15 @@ func (u *UpdateSchema) addColumn(path []string, fieldType 
iceberg.Type, doc stri
                }
 
                parentID = parentField.ID
+
+               // Walk up from the parent so a deleted ancestor is caught too. 
For a
+               // list or map, parentID is the element or value struct, and 
its parent
+               // in u.parentID is the list or map column itself.
+               for id := parentID; id != TableRootID; id = u.findParentID(id) {

Review Comment:
   Could we move this walk into a small helper and call it from 
[`unionAddColumn`](https://github.com/apache/iceberg-go/blob/956a014ef4dae83a33f2c56062c0673055f475e0/table/update_schema.go#L826-L879)
 as well? That function resolves the parent the same way but never checks 
deletes. So `DeleteColumn(address)` followed by `UnionByNameWith` adding 
`address.country` still gets nil from `Apply()`, and the column is gone. `main` 
does the same, but a union+delete test case here would cover the second entry 
point too.



##########
table/update_schema.go:
##########
@@ -402,6 +402,15 @@ func (u *UpdateSchema) addColumn(path []string, fieldType 
iceberg.Type, doc stri
                }
 
                parentID = parentField.ID
+
+               // Walk up from the parent so a deleted ancestor is caught too. 
For a
+               // list or map, parentID is the element or value struct, and 
its parent
+               // in u.parentID is the list or map column itself.
+               for id := parentID; id != TableRootID; id = u.findParentID(id) {
+                       if u.isDeleted(id) {
+                               return fmt.Errorf("cannot add to a column that 
will be deleted: %s", parentFullPath)

Review Comment:
   For the grandparent case this reports `address.geo`, but the column being 
deleted is `address`. Using the deleted id from the loop names the right 
column, the way 
[`checkIdentifierNotDeleted`](https://github.com/apache/iceberg-go/blob/956a014ef4dae83a33f2c56062c0673055f475e0/table/update_schema.go#L282-L286)
 already does. The grandparent test expectation would change to `address`.
   
   ```suggestion
                                name, _ := u.schema.FindColumnName(id)
                                return fmt.Errorf("cannot add to a column that 
will be deleted: %s", name)
   ```



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