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

   Closes #2452.
   
   If a table's `last-column-id` is lower than a field ID already in use, 
`UpdateSchema` hands out a duplicate ID when adding a column, and `Apply()` / 
`Commit()` panic in `iceberg.NewSchema` instead of returning an error. Parsing 
accepts this metadata, so the table loads normally and only crashes on the 
first schema update.
   
   `NewUpdateSchema` now runs the existing 
`MetadataBuilder.validateLastColumnID()` check after it seeds its counter from 
`last-column-id`. The error is stored in `u.err`, so `Apply()`, 
`BuildUpdates()` and `Commit()` return `ErrInvalidMetadata`. 
   
   Before:
   ```
   panic: invalid schema: multiple fields for id 3: z and w
   ```
   
   After:
   ```
   invalid metadata: last-column-id 2 is less than the highest field ID 3 in 
schemas
   ```
   
   ### Testing
   - Adds `TestUpdateSchemaLastColumnIDBelowHighestFieldIDReturnsError`. It 
sets `last-column-id` to 2 in `ExampleTableMetadataV2` (highest field ID is 3) 
and checks that `Apply()` and `Commit()` return `ErrInvalidMetadata` without 
panicking. The test fails without the fix.
   - `go test ./...` passes.
   


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