Anurag-S1ngh opened a new pull request, #19275:
URL: https://github.com/apache/iceberg/pull/19275

   ## Summary
   
   - `BaseUpdatePartitionSpec` recycled a historical partition field whenever 
its source and transform matched, without checking the current spec. On a v1 
table upgraded to v2, the old field ID can still be present as a void field, so 
the new spec ends up with duplicate IDs. A recycled name can also collide with 
a live field and make the add fail.
   - Only recycle a historical field when its ID and name are unused in the 
current spec and among fields added in the same update. Otherwise create a 
fresh field with a new ID, and let the existing void-renaming logic resolve the 
name.
   
   ## Changes
   
   - `BaseUpdatePartitionSpec.recycleOrCreatePartitionField`: add a 
`canRecycle` check for current and newly added fields.
   - `TestUpdatePartitionSpec`: add the v1 upgrade case and the v2 
name-conflict case from the issue.
   
   ## Testing
   
   - `./gradlew :iceberg-core:test --tests 
"org.apache.iceberg.TestUpdatePartitionSpec"` passes.
   - Both new tests fail on the unmodified code with the reported duplicate ID 
and `Cannot add duplicate partition field name: null` errors.
   - `spotlessApply` run for the module.
   
   Closes #19270
   


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