Skip to content

Commit f86b857

Browse files
committed
remove .db for all but dynamo/glue/hive
1 parent 9185389 commit f86b857

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ def _get_default_warehouse_location(self, database_name: str, table_name: str) -
930930

931931
if warehouse_path := self.properties.get(WAREHOUSE_LOCATION):
932932
warehouse_path = warehouse_path.rstrip("/")
933-
return f"{warehouse_path}/{database_name}.db/{table_name}"
933+
return f"{warehouse_path}/{database_name}/{table_name}"
934934

935935
raise ValueError("No default path is set, please specify a location when creating a table")
936936

pyiceberg/catalog/dynamodb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
from pyiceberg.catalog import (
3333
BOTOCORE_SESSION,
3434
ICEBERG,
35+
LOCATION,
3536
METADATA_LOCATION,
3637
PREVIOUS_METADATA_LOCATION,
3738
TABLE_TYPE,
39+
WAREHOUSE_LOCATION,
3840
MetastoreCatalog,
3941
PropertiesUpdateSummary,
4042
)
@@ -652,6 +654,19 @@ def _convert_dynamo_table_item_to_iceberg_table(self, dynamo_table_item: Dict[st
652654
catalog=self,
653655
)
654656

657+
def _get_default_warehouse_location(self, database_name: str, table_name: str) -> str:
658+
"""Return the default warehouse location following the Hive convention of `warehousePath/databaseName.db/tableName`."""
659+
database_properties = self.load_namespace_properties(database_name)
660+
if database_location := database_properties.get(LOCATION):
661+
database_location = database_location.rstrip("/")
662+
return f"{database_location}/{table_name}"
663+
664+
if warehouse_path := self.properties.get(WAREHOUSE_LOCATION):
665+
warehouse_path = warehouse_path.rstrip("/")
666+
return f"{warehouse_path}/{database_name}.db/{table_name}"
667+
668+
raise ValueError("No default path is set, please specify a location when creating a table")
669+
655670

656671
def _get_create_table_item(database_name: str, table_name: str, properties: Properties, metadata_location: str) -> Dict[str, Any]:
657672
current_timestamp_ms = str(round(time() * 1000))

pyiceberg/catalog/glue.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
METADATA_LOCATION,
4949
PREVIOUS_METADATA_LOCATION,
5050
TABLE_TYPE,
51+
WAREHOUSE_LOCATION,
5152
MetastoreCatalog,
5253
PropertiesUpdateSummary,
5354
)
@@ -808,3 +809,16 @@ def view_exists(self, identifier: Union[str, Identifier]) -> bool:
808809
@staticmethod
809810
def __is_iceberg_table(table: TableTypeDef) -> bool:
810811
return table.get("Parameters", {}).get(TABLE_TYPE, "").lower() == ICEBERG
812+
813+
def _get_default_warehouse_location(self, database_name: str, table_name: str) -> str:
814+
"""Return the default warehouse location following the Hive convention of `warehousePath/databaseName.db/tableName`."""
815+
database_properties = self.load_namespace_properties(database_name)
816+
if database_location := database_properties.get(LOCATION):
817+
database_location = database_location.rstrip("/")
818+
return f"{database_location}/{table_name}"
819+
820+
if warehouse_path := self.properties.get(WAREHOUSE_LOCATION):
821+
warehouse_path = warehouse_path.rstrip("/")
822+
return f"{warehouse_path}/{database_name}.db/{table_name}"
823+
824+
raise ValueError("No default path is set, please specify a location when creating a table")

pyiceberg/catalog/hive.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
LOCATION,
6464
METADATA_LOCATION,
6565
TABLE_TYPE,
66+
WAREHOUSE_LOCATION,
6667
MetastoreCatalog,
6768
PropertiesUpdateSummary,
6869
)
@@ -790,3 +791,16 @@ def update_namespace_properties(
790791

791792
def drop_view(self, identifier: Union[str, Identifier]) -> None:
792793
raise NotImplementedError
794+
795+
def _get_default_warehouse_location(self, database_name: str, table_name: str) -> str:
796+
"""Return the default warehouse location following the Hive convention of `warehousePath/databaseName.db/tableName`."""
797+
database_properties = self.load_namespace_properties(database_name)
798+
if database_location := database_properties.get(LOCATION):
799+
database_location = database_location.rstrip("/")
800+
return f"{database_location}/{table_name}"
801+
802+
if warehouse_path := self.properties.get(WAREHOUSE_LOCATION):
803+
warehouse_path = warehouse_path.rstrip("/")
804+
return f"{warehouse_path}/{database_name}.db/{table_name}"
805+
806+
raise ValueError("No default path is set, please specify a location when creating a table")

0 commit comments

Comments
 (0)