smaheshwar-pltr commented on code in PR #13225:
URL: https://github.com/apache/iceberg/pull/13225#discussion_r4719248514


##########
core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java:
##########
@@ -217,6 +245,27 @@ public void commit(TableMetadata base, TableMetadata 
metadata) {
             String.format("Update type %s is not supported", updateType));
     }
 
+    if (base != null) {
+      boolean encryptionKeyRemoved =
+          base.properties().containsKey(TableProperties.ENCRYPTION_TABLE_KEY)
+              && 
!metadata.properties().containsKey(TableProperties.ENCRYPTION_TABLE_KEY);
+      Preconditions.checkArgument(
+          !encryptionKeyRemoved, "Cannot remove key ID from an encrypted 
table");
+
+      boolean encryptionKeyUnchanged =
+          Objects.equals(
+              base.properties().get(TableProperties.ENCRYPTION_TABLE_KEY),
+              metadata.properties().get(TableProperties.ENCRYPTION_TABLE_KEY));
+      Preconditions.checkArgument(
+          encryptionKeyUnchanged, "Cannot modify key ID of an encrypted 
table");
+    } else {
+      // a create transaction writes its files with tableKeyId, read from the 
staged table

Review Comment:
   On https://github.com/apache/iceberg/pull/13225#issuecomment-6643863317: for 
now, given REST tables take a different path to Hive here and this case is 
rare, I've decided to just disallow it. I've added REST-specific tests in 
`TestRESTCatalog` that explicitly hit this rare codepath (I don't think you can 
actually reach it with Spark SQL).



##########
core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java:
##########
@@ -155,6 +181,9 @@ enum UpdateType {
     }
     this.endpoints = endpoints;
     this.readQueryParams = readQueryParams;
+
+    // CREATE operations need encryption configured before current metadata is 
available.
+    encryptionPropsFromMetadata(current);

Review Comment:
   TODO: See 
https://github.com/apache/iceberg/pull/13225#issuecomment-6643863317, need to 
handle the transaction case similar to Hive but without the 
https://github.com/apache/iceberg/pull/18798 bug. Or ideally a centralisation 
effort like https://github.com/apache/iceberg/pull/18799 would reduce bugs like 
this more generally



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