HonahX commented on code in PR #947: URL: https://github.com/apache/iceberg-python/pull/947#discussion_r1685322960
########## tests/catalog/test_glue.py: ########## @@ -46,6 +47,23 @@ ) +@mock_aws +def test_load_catalog_from_impl() -> None: + assert isinstance( + load_catalog( + "catalog", + **{ + PY_CATALOG_IMPL: "pyiceberg.catalog.glue.GlueCatalog", Review Comment: [Optional] I think it would be better to explicitly write the config name "py-catalog-impl" in tests ########## 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(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_(properties) Review Comment: ```suggestion return class_(name, **properties) ``` The Catalog has one required argument "name", and take properties as kwargs. We need to pass the arguments like this otherwise the catalog implementation cannot pick-up the properties. The name can be obtained from `load_catalog` ########## tests/catalog/test_glue.py: ########## @@ -46,6 +47,23 @@ ) +@mock_aws +def test_load_catalog_from_impl() -> None: + assert isinstance( + load_catalog( + "catalog", + **{ + PY_CATALOG_IMPL: "pyiceberg.catalog.glue.GlueCatalog", + "region_name": "us-east-1", + "aws_access_key_id": "access-key", + "aws_secret_access_key": "secret-key", + "aws_session_token": "session-token", Review Comment: These property names will be deprecated in the upcoming release: https://github.com/apache/iceberg-python/pull/922 How about using the new `glue.` config names here: https://github.com/apache/iceberg-python/blob/d0bfb4a67bccd15c2d2e9baa481a5f33fe4c5220/mkdocs/docs/configuration.md?plain=1#L312-L315 -- 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