rambleraptor commented on code in PR #144:
URL:
https://github.com/apache/terraform-provider-iceberg/pull/144#discussion_r4620557803
##########
internal/provider/resource_table.go:
##########
@@ -497,121 +505,130 @@ func (r *icebergTableResource)
calculateSchemaUpdates(ctx context.Context, plan,
return nil
}
- // Find the highest existing schema ID to ensure the new one is unique.
- maxSchemaID := int64(0)
- for _, s := range tbl.Metadata().Schemas() {
- if int64(s.ID) > maxSchemaID {
- maxSchemaID = int64(s.ID)
- }
+ if tbl.Schema().Equals(planIceberg) {
+ return nil
}
- newSchemaID := maxSchemaID + 1
- planSchema.ID = types.Int64Value(newSchemaID)
- planIceberg, err = planSchema.ToIceberg()
- if err != nil {
- diags.AddError("failed to convert plan schema with new ID",
err.Error())
-
- return nil
+ // Returning to an earlier schema: point back at its existing ID.
+ maxSchemaID := 0
+ for _, existing := range tbl.Metadata().Schemas() {
+ if existing.Equals(planIceberg) {
Review Comment:
Great point! I moved the existing-schema lookup above
validateSchemaEvolution here, so validation only runs on genuinely new schemas.
#135 can add validateNewFieldIDs after that point.
--
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]