RussellSpitzer commented on code in PR #17984:
URL: https://github.com/apache/iceberg/pull/17984#discussion_r3991280224


##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -365,7 +376,37 @@ public Snapshot apply() {
         manifestList.location(),
         nextRowId,
         assignedRows,
-        writer.toManifestListFile().encryptionKeyID());
+        manifestListFile.encryptionKeyID());
+  }
+
+  /**
+   * Returns the encryption key records required to read a manifest list.
+   *
+   * <p>The manifest list key metadata is encrypted by a key encryption key, 
so both records must be
+   * present in table metadata. Unencrypted manifest lists require no keys.
+   */
+  private static List<EncryptedKey> findEncryptionKeysForManifestList(

Review Comment:
   Both of the exceptions here are CommitFailedExceptions, which means we 
expect that SnapshotProducer should be able to retry and succeed. I don't think 
either of these will actually ever succeed if they fail a single time.
   
   Probably should be Preconditions instead
   
   --------
   
   This function also is a bit confusing because it tries to address two 
different use cases at once
   Finding Keys when there should be ones
   Doing nothing when there are no keys. 
   
   Generally we would just change the caller to be something like
   
   ```java
   this.encryptionKeysForManifestList =
       manifestListFile.encryptionKeyID() == null
           ? List.of()
           : requiredManifestListKeys(encryption, 
manifestListFile.encryptionKeyID()); // This renamed
   ```
   
   That way this function can stick to a single behavior and the two paths 
(Unencrypted and Encrypted)  stay separate 
   



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