akritishakya opened a new pull request, #2723:
URL: https://github.com/apache/iceberg-go/pull/2723

   Closes #1687 
   
   ## Problem
   
   When a single `UpdateSchema` deletes a column and then adds a column under 
it, or anywhere below it, `AddColumn` accepts the add but `Apply()` drops it. 
`Commit()` returns `nil`, so the caller is not told that the new column was not 
added.
   
   `addColumn` resolves the parent from the original schema, where the deleted 
column still exists, and does not check pending deletes. In `Apply()`, the 
visitor removes the deleted column before it reads the adds under it, so they 
are discarded.
   
   ## Fix
   
   - `addColumn` now walks from the parent up to the table root through 
`u.parentID`, and fails with `cannot add to a column that will be deleted: 
<parent path>` if the parent or any ancestor is being deleted.
   - Walking the ancestors also covers a deleted grandparent (delete `a`, add 
`a.b.x`), where the direct parent is not itself deleted.
   - It also covers a deleted `list<struct>` or `map<_, struct>` column, where 
`addColumn` adds into the element or value struct, which has a different field 
ID than the list or map column.
   - The reverse order (add `a.x`, then delete `a`) is unchanged: 
`deleteColumn` already rejects it with `field that has additions cannot be 
deleted`.
   
   ## Tests
   
   New `TestAddColumnUnderDeletedParent` in `table/update_schema_test.go` 
covers:
   
   - a deleted struct parent, a deleted grandparent, a deleted `list<struct>` 
and a deleted `map<string, struct>` (rejected)
   - add then delete the parent (rejected by the existing check)
   - a deleted sibling (the new column is added)
   
   The tests that expect `cannot add to a column that will be deleted` fail 
without this 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