Skip to content

Commit 15236de

Browse files
committed
use WAREHOUSE property
1 parent 8a0a6da commit 15236de

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

pyiceberg/catalog/memory.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
NoSuchTableError,
2121
TableAlreadyExistsError,
2222
)
23+
from pyiceberg.io import WAREHOUSE
2324
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec
2425
from pyiceberg.schema import Schema
2526
from pyiceberg.table import (
@@ -41,12 +42,11 @@ class InMemoryCatalog(Catalog):
4142
__tables: Dict[Identifier, Table]
4243
__namespaces: Dict[Identifier, Properties]
4344

44-
def __init__(self, name: str, warehouse_location: Optional[str] = None, **properties: str) -> None:
45+
def __init__(self, name: str, **properties: str) -> None:
4546
super().__init__(name, **properties)
46-
47-
self._warehouse_location = warehouse_location or DEFAULT_WAREHOUSE_LOCATION
4847
self.__tables = {}
4948
self.__namespaces = {}
49+
self._warehouse_location = properties.get(WAREHOUSE, None) or DEFAULT_WAREHOUSE_LOCATION
5050

5151
def create_table(
5252
self,
@@ -70,7 +70,6 @@ def create_table(
7070
if not location:
7171
location = f'{self._warehouse_location}/{"/".join(identifier)}'
7272

73-
# _get_default_warehouse_location
7473
metadata_location = f'{self._warehouse_location}/{"/".join(identifier)}/metadata/metadata.json'
7574

7675
metadata = new_table_metadata(

tests/catalog/test_base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
NoSuchTableError,
3434
TableAlreadyExistsError,
3535
)
36+
from pyiceberg.io import WAREHOUSE
3637
from pyiceberg.partitioning import PartitionField, PartitionSpec
3738
from pyiceberg.schema import Schema
3839
from pyiceberg.table import (
@@ -49,9 +50,7 @@
4950

5051
@pytest.fixture
5152
def catalog(tmp_path: PosixPath) -> InMemoryCatalog:
52-
return InMemoryCatalog(
53-
"test.in.memory.catalog", warehouse_location=tmp_path.absolute().as_posix(), **{"test.key": "test.value"}
54-
)
53+
return InMemoryCatalog("test.in.memory.catalog", **{WAREHOUSE: tmp_path.absolute().as_posix(), "test.key": "test.value"})
5554

5655

5756
TEST_TABLE_IDENTIFIER = ("com", "organization", "department", "my_table")

0 commit comments

Comments
 (0)