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


##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -396,6 +398,26 @@ def _create_session(self) -> Session:
 
         return session
 
+    @staticmethod
+    def _resolve_storage_credentials(storage_credentials: 
list[StorageCredential], location: str | None) -> Properties:
+        """Resolve the best-matching storage credential by longest prefix 
match.
+
+        Mirrors the Java implementation in S3FileIO.clientForStoragePath() 
which iterates
+        over storage credential prefixes and selects the one with the longest 
match.
+
+        See: 
https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java
+        """
+        if not storage_credentials or not location:
+            return {}
+
+        best_match: StorageCredential | None = None
+        for cred in storage_credentials:
+            if location.startswith(cred.prefix):
+                if best_match is None or len(cred.prefix) > 
len(best_match.prefix):

Review Comment:
   looks good 👍 , 
https://github.com/apache/iceberg/blob/175e6c241ea178b8a4fb6ea16bd801b3c7fc3b91/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java#L379-L396



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