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


##########
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:
   Done, it uses `FindColumnName` on the deleted id now like 
`checkIdentifierNotDeleted`, so the grandparent case says `address`. Dropped 
the `parentFullPath` param since nothing uses it anymore, and fixed the test 
expectation.



##########
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:
   Yeah `DeleteColumn(address)` + `UnionByNameWith` with `address.country` 
returned nil and the column was just dropped. Pulled the loop out into 
`checkParentNotDeleted` and called it from `unionAddColumn` too. Added a `union 
by name` case to the test as well, it fails without the change.



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