LuciferYang opened a new pull request, #1012:
URL: https://github.com/apache/iceberg-cpp/pull/1012

   ## What
   
   `TableMetadataBuilder::Impl::RemoveSchemas` removed schemas from 
`metadata_.schemas` but left them in `schemas_by_id_`. In the same builder, 
`SetCurrentSchema` on a removed id then passed its existence check, and 
`Build()` produced metadata whose `current-schema-id` pointed outside 
`schemas`. Catalog commits apply the caller's update list on one builder and 
write the result, so a commit carrying `[remove-schemas, set-current-schema]` 
could write a metadata file that no longer loads.
   
   Closes #1011.
   
   ## How
   
   Erase the removed ids from `schemas_by_id_` alongside the existing filter of 
`metadata_.schemas`. Java's `Builder.removeSchemas` does not update 
`schemasById` either, so this is stricter than Java's builder.
   
   ## Testing
   
   Two tests in `table_metadata_builder_test.cc`:
   
   - `RemoveSchemasDropsIndexEntry`: after `RemoveSchemas({1})`, 
`SetCurrentSchema(1)` makes `Build()` fail with `Cannot set current schema to 
unknown schema: 1`. Without the fix `Build()` returns metadata with the 
dangling id.
   - `AddSchemaAfterRemoveNotConfusedByStaleIndex`: re-adding the removed 
schema puts it back in `schemas`. Without the fix the stale index entry makes 
`AddSchema` skip it and `schemas` stays at one entry.
   
   `RemovePartitionSpecs` has the same gap with `specs_by_id_`; I'll send that 
separately.
   


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