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

   Fixes #2828
   
   `UpdateSchema.DeleteColumn` dropped a column that is the source of a field 
in the default partition spec, and the commit succeeded. The metadata then had 
a default spec that referenced a column missing from the current schema. Java 
rejects the same change, and its parser fails to load such metadata.
   
   ### Cause
   
   - `MetadataBuilder.Build` checks the default sort order against the current 
schema in `checkSortOrders`. That is why dropping a sort order source column is 
already rejected.
   - `checkPartitionSpecs` only checks for duplicate spec IDs and that the 
default spec exists. Nothing checks its source columns against the current 
schema.
   
   ### Fix
   
   - `checkDefaultSpecSources` returns `ErrInvalidMetadata` when a field of the 
default spec has a source column that the current schema does not have. The 
message names the field, like Java's `Cannot find source column for partition 
field`.
   - `void` fields are skipped, as in Java. v1 keeps a removed partition field 
as `void` with its old source ID, so that column can still be dropped.
   - Older specs are not checked, as in Java. A column used only by a 
historical spec can still be dropped.
   - The check runs on every `Build`, as in Java. Reading metadata is 
unchanged, so a table already written this way can still be loaded and scanned 
in Go. Java cannot load such a table at all.
   - A scan fixture and an inspect fixture built metadata whose default spec 
referenced a dropped column. They now add an unpartitioned default spec, so the 
spec under test stays as an older spec, as it would in a real table.
   
   ### Tests
   
   - `TestDeleteDefaultPartitionSourceColumn/source_of_default_spec`: drops the 
source of an `identity` field and checks that `StagedTable` returns 
`ErrInvalidMetadata`.
   - `TestDeleteDefaultPartitionSourceColumn/source_of_historical_spec_only`: 
removes the partition field on v2 first, then drops the column.
   - `TestDeleteDefaultPartitionSourceColumn/source_of_v1_void_field`: removes 
the partition field on v1, which keeps it as `void`, then drops the column.
   


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