advancedxy commented on code in PR #10755:
URL: https://github.com/apache/iceberg/pull/10755#discussion_r1860976419


##########
core/src/main/java/org/apache/iceberg/UpdateRequirements.java:
##########
@@ -173,6 +175,27 @@ private void update(MetadataUpdate.SetDefaultSortOrder 
unused) {
       }
     }
 
+    private void update(MetadataUpdate.RemovePartitionSpecs unused) {
+      // require that the default partition spec has not changed
+      if (!setSpecId) {
+        if (base != null && !isReplace) {
+          require(new 
UpdateRequirement.AssertDefaultSpecID(base.defaultSpecId()));
+        }
+        this.setSpecId = true;
+      }
+
+      // require that no branches have changed, so that old specs won't be 
written.
+      if (base != null && !isReplace) {
+        base.refs()
+            .forEach(
+                (name, ref) -> {
+                  if (ref.isBranch() && !name.equals(SnapshotRef.MAIN_BRANCH)) 
{
+                    require(new UpdateRequirement.AssertRefSnapshotID(name, 
ref.snapshotId()));

Review Comment:
   I updated the `TestUpdateRequirements`. However, it's hard to test the 
failure cases in CatalogTests: before committing, the `internalApply` also 
refreshes the base table, so we cannot create a concurrent update to base table 
easily, which has to be after the refresh and before commit.  Do you have any 
suggestions?



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to