Skip to content

Commit bdb7fef

Browse files
committed
check uri property in config
1 parent 95f6273 commit bdb7fef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ def infer_catalog_type(name: str, catalog_properties: RecursiveDict) -> CatalogT
218218
)
219219

220220

221+
def _check_required_catalog_properties(name: str, catalog_type: CatalogType, conf: RecursiveDict) -> None:
222+
"""Validate required properties for explicitly selected catalog types."""
223+
if catalog_type in {CatalogType.REST, CatalogType.HIVE, CatalogType.SQL} and URI not in conf:
224+
raise ValueError(
225+
f"URI missing, please provide using --uri, the config or environment variable PYICEBERG_CATALOG__{name.upper()}__URI"
226+
)
227+
228+
221229
def load_catalog(name: str | None = None, **properties: str | None) -> Catalog:
222230
"""Load the catalog based on the properties.
223231
@@ -263,6 +271,7 @@ def load_catalog(name: str | None = None, **properties: str | None) -> Catalog:
263271
catalog_type = infer_catalog_type(name, conf)
264272

265273
if catalog_type:
274+
_check_required_catalog_properties(name, catalog_type, conf)
266275
return AVAILABLE_CATALOGS[catalog_type](name, cast(dict[str, str], conf))
267276

268277
raise ValueError(f"Could not initialize catalog with the following properties: {properties}")

0 commit comments

Comments
 (0)