Skip to content

Commit b251226

Browse files
author
Jack Ye
committed
address comments
1 parent 1ec1055 commit b251226

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def load_catalog(name: Optional[str] = None, **properties: Optional[str]) -> Cat
233233
conf: RecursiveDict = merge_config(env or {}, cast(RecursiveDict, properties))
234234

235235
if catalog_impl := properties.get(PY_CATALOG_IMPL):
236-
if catalog := _import_catalog(catalog_impl, properties):
236+
if catalog := _import_catalog(name, catalog_impl, properties):
237237
logger.info("Loaded Catalog: %s", catalog_impl)
238238
return catalog
239239
else:
@@ -292,15 +292,15 @@ def delete_data_files(io: FileIO, manifests_to_delete: List[ManifestFile]) -> No
292292
deleted_files[path] = True
293293

294294

295-
def _import_catalog(catalog_impl: str, properties: Properties) -> Optional[Catalog]:
295+
def _import_catalog(name: str, catalog_impl: str, properties: Properties) -> Optional[Catalog]:
296296
try:
297297
path_parts = catalog_impl.split(".")
298298
if len(path_parts) < 2:
299299
raise ValueError(f"py-catalog-impl should be full path (module.CustomCatalog), got: {catalog_impl}")
300300
module_name, class_name = ".".join(path_parts[:-1]), path_parts[-1]
301301
module = importlib.import_module(module_name)
302302
class_ = getattr(module, class_name)
303-
return class_(properties)
303+
return class_(name, **properties)
304304
except ModuleNotFoundError:
305305
logger.warning("Could not initialize Catalog: %s", catalog_impl)
306306
return None

tests/catalog/test_glue.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pytest
2323
from moto import mock_aws
2424

25-
from pyiceberg.catalog import PY_CATALOG_IMPL, load_catalog
25+
from pyiceberg.catalog import load_catalog
2626
from pyiceberg.catalog.glue import GlueCatalog
2727
from pyiceberg.exceptions import (
2828
NamespaceAlreadyExistsError,
@@ -53,11 +53,11 @@ def test_load_catalog_from_impl() -> None:
5353
load_catalog(
5454
"catalog",
5555
**{
56-
PY_CATALOG_IMPL: "pyiceberg.catalog.glue.GlueCatalog",
57-
"region_name": "us-east-1",
58-
"aws_access_key_id": "access-key",
59-
"aws_secret_access_key": "secret-key",
60-
"aws_session_token": "session-token",
56+
"py-catalog-impl": "pyiceberg.catalog.glue.GlueCatalog",
57+
"glue.region_name": "us-east-1",
58+
"glue.aws_access_key_id": "access-key",
59+
"glue.aws_secret_access_key": "secret-key",
60+
"glue.aws_session_token": "session-token",
6161
},
6262
),
6363
GlueCatalog,

0 commit comments

Comments
 (0)