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


##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:
##########
@@ -207,34 +157,16 @@ the table key parameter (along with existing snapshots) 
in the file, making the
     if (tableKeyIdFromHMS != null) {
       checkIntegrityForEncryption(tableKeyIdFromHMS, dekLengthFromHMS, 
metadataHashFromHMS);
 
-      tableKeyId = tableKeyIdFromHMS;
-      encryptionDekLength =
-          (dekLengthFromHMS != null)
-              ? Integer.parseInt(dekLengthFromHMS)
-              : TableProperties.ENCRYPTION_DEK_LENGTH_DEFAULT;
-
-      // Open transactions may still need keys that are not in committed 
metadata. After an
-      // earlier refresh discarded the manager, those keys are only in 
encryptedKeys.
-      Iterable<EncryptedKey> knownKeys =
-          encryptionManager != null
-              ? EncryptionUtil.encryptionKeys(encryptionManager).values()
-              : encryptedKeys;
-      Map<String, EncryptedKey> keysById = Maps.newLinkedHashMap();
-      current().encryptionKeys().forEach(key -> keysById.put(key.keyId(), 
key));
-      knownKeys.forEach(key -> keysById.putIfAbsent(key.keyId(), key));
-      encryptedKeys = List.copyOf(keysById.values());
-
-      // Force re-creation of encryption manager with updated keys
-      encryptingFileIO = null;
-      encryptionManager = null;
+      tableEncryption.useCatalogKeyId(
+          tableKeyIdFromHMS, dekLengthFromHMS, current().encryptionKeys());
     }
   }
 
   @SuppressWarnings({"checkstyle:CyclomaticComplexity", "MethodLength"})
   @Override
   protected void doCommit(TableMetadata base, TableMetadata metadata) {
     boolean newTable = base == null;
-    encryptionPropsFromMetadata(metadata.properties());
+    tableEncryption.useUncommittedProperties(metadata.properties());

Review Comment:
   With #18798 rebased onto this PR, this call and the one in `temp().io()` go 
through a small Hive helper that skips tables HMS already has, so a rejected 
`ALTER TABLE ... SET TBLPROPERTIES ('encryption.key-id'=...)` can't leave the 
table operations encrypting: 
https://github.com/smaheshwar-pltr/iceberg/commit/aa81dd4fbe94c103f190791520df10560d0c0f28



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