viirya opened a new issue, #3677:
URL: https://github.com/apache/iceberg-rust/issues/3677

   ### Apache Iceberg Rust version
   
   main (cfbfb2789)
   
   ### Describe the bug
   
   `UpdateSchemaAction` accepts adding a column under a parent that the same 
update deletes, then drops the addition when it rebuilds the schema:
   
   ```rust
   tx.update_schema()
       .delete_column("person")
       
.add_column(AddColumn::builder().name("email").field_type(string).parent("person").build())
   ```
   
   The commit succeeds, and the new schema has neither `person` nor 
`person.email`. The ID assigned to `email` is not in the new schema, so 
`last-column-id` (the max of the old value and `schema.highest_field_id()`) 
doesn't count it, and a later update can assign the same ID to a different 
column.
   
   The same happens when deleting a list or map column and adding into its 
element or value struct (`delete_column("props")` + `add_column(... 
.parent("props"))`).
   
   The nested name-conflict check skips conflicts when the resolved parent is 
deleted, so nothing rejects this case.
   
   ### Expected behavior
   
   Reject the update. Java's `SchemaUpdate.addColumn` throws `Cannot add to a 
column that will be deleted` when the parent is deleted, and `deleteColumn` 
throws `Cannot delete a column that has additions`.
   
   Java compares against the resolved parent ID, which is the value or element 
ID for a map or list, and only checks the direct parent. So Java accepts 
deleting a map or list field (or an ancestor struct) and adding into its value, 
element, or nested struct, and drops the addition the same way. The addition is 
lost either way, so iceberg-rust should reject these cases too.
   
   ### Willingness to contribute
   
   I can contribute a fix for this bug independently
   
   Found while reviewing #3665.
   


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