rambleraptor opened a new pull request, #190:
URL: https://github.com/apache/terraform-provider-iceberg/pull/190

   Related to #112 (Prevent reuse of historical partition field IDs).
   
   A partition field ID identifies one source and transform for the life of a 
v2+ table. Data files written under an older spec record partition values by 
field ID, so giving a dropped field's ID to a different source or transform 
changes what those values mean. The provider committed such specs without 
complaint.
   
   `calculatePartitionUpdates` now checks each planned partition field against 
every spec the table has had, before it builds the new spec:
   
   - **Explicit ID the table already assigned:** it must keep the same source 
IDs and transform. Renaming is fine.
   - **Any other explicit ID:** it must be above `last-partition-id`. This 
matches the schema field check in #135.
   - **No ID:** the field reuses the ID the table already has for its source 
IDs and transform, as Java's `UpdatePartitionSpec` does in v2. Otherwise it 
gets the next unused ID.
   
   The third rule fixes a related bug. Omitted IDs used to be numbered from 
1000 with no table context, so after a spec replacement they could collide with 
historical fields without the user writing any ID. One of the new unit test 
cases covers this, and it fails without the fix.
   
   v1 tables are unchanged, because v1 numbers partition fields sequentially 
from 1000 in every spec.
   
   **Behavior change:** a config that hard-codes `field_id` and then changes 
that field's source or transform now gets an `invalid partition field id` 
error. `TestAccIcebergTablePartitionSpecAndSortOrder` did exactly this, reusing 
`field_id = 1000` when going from `bucket[16]` to `bucket[32]`. It now leaves 
`field_id` computed and expects the new field to get `1001`.
   
   ## Testing
   
   - New `TestCalculatePartitionUpdatesPartitionFieldIDs` cases: a dropped ID 
reused with a different transform, a different source, or an unused ID at or 
below `last-partition-id` (all rejected); reusing a dropped ID for the same 
field under a new name; a new ID above `last-partition-id`; and omitted IDs, 
which reuse or allocate and skip IDs the plan sets explicitly.
   - `go test ./...`
   - `TF_ACC=1 go test ./internal/provider -run '^TestAcc'` against 
`dev/docker-compose.yml`
   


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