Skip to content

Commit

Permalink
use WAREHOUSE property
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjqliu committed Jan 22, 2024
1 parent 8a0a6da commit 15236de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions pyiceberg/catalog/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
Expand All @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions tests/catalog/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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")
Expand Down

0 comments on commit 15236de

Please sign in to comment.