jackye1995 commented on code in PR #947:
URL: https://github.com/apache/iceberg-python/pull/947#discussion_r1685520033


##########
pyiceberg/catalog/__init__.py:
##########
@@ -283,6 +292,20 @@ def delete_data_files(io: FileIO, manifests_to_delete: 
List[ManifestFile]) -> No
                 deleted_files[path] = True
 
 
+def _import_catalog(name: str, catalog_impl: str, properties: Properties) -> 
Optional[Catalog]:
+    try:
+        path_parts = catalog_impl.split(".")
+        if len(path_parts) < 2:
+            raise ValueError(f"py-catalog-impl should be full path 
(module.CustomCatalog), got: {catalog_impl}")
+        module_name, class_name = ".".join(path_parts[:-1]), path_parts[-1]
+        module = importlib.import_module(module_name)
+        class_ = getattr(module, class_name)
+        return class_(name, **properties)

Review Comment:
   I copied the logic from `_import_file_io`. It would naturally fail anyway 
even if it is not explicitly caught, so I guess it is fine, but I could also do 
a catch all. Let me know what is the standard way here.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to