kevinjqliu commented on code in PR #4159:
URL: https://github.com/apache/iceberg-python/pull/4159#discussion_r4495477344


##########
tests/table/encryption/manifest-list-v3-encrypted.avro:
##########


Review Comment:
   i double check the content of the avro file. looks fine, used for testing



##########
pyiceberg/table/__init__.py:
##########
@@ -1345,13 +1347,29 @@ def __init__(
         io: FileIO,
         catalog: Catalog,
         config: dict[str, str] = EMPTY_DICT,
+        kms_client: KeyManagementClient | None = None,
     ) -> None:
         self._identifier = identifier
         self.metadata = metadata
         self.metadata_location = metadata_location
         self.io = io
         self.catalog = catalog
         self.config = config
+        self._kms_client = kms_client
+        self._encryption_manager: tuple[TableMetadata, EncryptionManager | 
None] | None = None

Review Comment:
   nit: this seems like a code smell to me. 
   
   I'm curious why `_encryption_manager` is a tuple, and the 
`encryption_manager` property returns just the second part of the tuple. 
   the first part of the tuple is table metadata which is also already 
represented by `self.metadata`. 
   



##########
tests/table/encryption/README.md:
##########
@@ -0,0 +1,25 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+-->
+
+# Encrypted manifest list test data
+
+`manifest-list-v3-encrypted.avro` is an empty manifest list encrypted by 
iceberg-rust, copied from its

Review Comment:
   ah yes, lets just add the include the avro file, we can rip it out later 
once we can use spark (or rust) for e2e test. 
   
   i'll finish up the rest of the review! 



##########
pyiceberg/table/snapshots.py:
##########
@@ -289,9 +290,21 @@ def __repr__(self) -> str:
         filtered_fields = [field for field in fields if field is not None]
         return f"Snapshot({', '.join(filtered_fields)})"
 
-    def manifests(self, io: FileIO) -> list[ManifestFile]:
-        """Return the manifests for the given snapshot."""
-        return list(_manifests(io, self.manifest_list))
+    def manifests(self, io: FileIO, encryption_manager: EncryptionManager | 
None = None) -> list[ManifestFile]:

Review Comment:
   👍 `encryption_manager` is passed all the way here and then is not needed 
anymore since the rest of the decryption is handled by the `key_metadata`



##########
pyiceberg/table/snapshots.py:
##########
@@ -289,9 +290,21 @@ def __repr__(self) -> str:
         filtered_fields = [field for field in fields if field is not None]
         return f"Snapshot({', '.join(filtered_fields)})"
 
-    def manifests(self, io: FileIO) -> list[ManifestFile]:
-        """Return the manifests for the given snapshot."""
-        return list(_manifests(io, self.manifest_list))
+    def manifests(self, io: FileIO, encryption_manager: EncryptionManager | 
None = None) -> list[ManifestFile]:

Review Comment:
   slight nit on readability, perhaps something like this to show clearly the 
encryption and non-encryption paths
   
   
   ```
   def manifests(self, io: FileIO, encryption_manager: EncryptionManager | None 
= None) -> list[ManifestFile]:
       """Return the manifests for the given snapshot.
   
       A snapshot has a `key-id` only when its manifest list is encrypted. The 
`key-id` names the entry
       in the table's `encryption-keys` that holds the manifest list's key.
   
       Args:
           io: Reads the manifest list.
           encryption_manager: Decrypts the manifest list, required when the 
snapshot has a `key-id`.
       """
       key_metadata: StandardKeyMetadata | None = None
       if self.key_id is not None:
           if encryption_manager is None:
               raise ValueError(f"Snapshot {self.snapshot_id} is encrypted, but 
no encryption manager was provided")
           key_metadata = 
encryption_manager.decrypt_manifest_list_key_metadata(self.key_id)
   
       return list(_manifests(io, self.manifest_list, key_metadata))
   ```



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