rambleraptor commented on code in PR #144:
URL: 
https://github.com/apache/terraform-provider-iceberg/pull/144#discussion_r4620956477


##########
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:
   That's a great point. Yeah, I'll make that change in 135. I also added that 
test which will help identify this when it's time to merge #135 



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