diff --git a/pyiceberg/catalog/memory.py b/pyiceberg/catalog/memory.py index 67ffb25f15..a9e42e428a 100644 --- a/pyiceberg/catalog/memory.py +++ b/pyiceberg/catalog/memory.py @@ -20,6 +20,7 @@ NoSuchTableError, TableAlreadyExistsError, ) +from pyiceberg.io import WAREHOUSE from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec from pyiceberg.schema import Schema from pyiceberg.table import ( @@ -41,12 +42,11 @@ class InMemoryCatalog(Catalog): __tables: Dict[Identifier, Table] __namespaces: Dict[Identifier, Properties] - def __init__(self, name: str, warehouse_location: Optional[str] = None, **properties: str) -> None: + def __init__(self, name: str, **properties: str) -> None: super().__init__(name, **properties) - - self._warehouse_location = warehouse_location or DEFAULT_WAREHOUSE_LOCATION self.__tables = {} self.__namespaces = {} + self._warehouse_location = properties.get(WAREHOUSE, None) or DEFAULT_WAREHOUSE_LOCATION def create_table( self, @@ -70,7 +70,6 @@ def create_table( if not location: location = f'{self._warehouse_location}/{"/".join(identifier)}' - # _get_default_warehouse_location metadata_location = f'{self._warehouse_location}/{"/".join(identifier)}/metadata/metadata.json' metadata = new_table_metadata( diff --git a/tests/catalog/test_base.py b/tests/catalog/test_base.py index d086c4239e..d237c0fc76 100644 --- a/tests/catalog/test_base.py +++ b/tests/catalog/test_base.py @@ -33,6 +33,7 @@ NoSuchTableError, TableAlreadyExistsError, ) +from pyiceberg.io import WAREHOUSE from pyiceberg.partitioning import PartitionField, PartitionSpec from pyiceberg.schema import Schema from pyiceberg.table import ( @@ -49,9 +50,7 @@ @pytest.fixture def catalog(tmp_path: PosixPath) -> InMemoryCatalog: - return InMemoryCatalog( - "test.in.memory.catalog", warehouse_location=tmp_path.absolute().as_posix(), **{"test.key": "test.value"} - ) + return InMemoryCatalog("test.in.memory.catalog", **{WAREHOUSE: tmp_path.absolute().as_posix(), "test.key": "test.value"}) TEST_TABLE_IDENTIFIER = ("com", "organization", "department", "my_table")