This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 6dab162e03 Python: Refactor catalog constants (#6277)
6dab162e03 is described below
commit 6dab162e03aac55f66e988cb401a58b45edde634
Author: Rushan Jiang <[email protected]>
AuthorDate: Sun Nov 27 11:59:11 2022 -0500
Python: Refactor catalog constants (#6277)
---
python/pyiceberg/catalog/hive.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/python/pyiceberg/catalog/hive.py b/python/pyiceberg/catalog/hive.py
index 3092be1ecb..12601f103f 100644
--- a/python/pyiceberg/catalog/hive.py
+++ b/python/pyiceberg/catalog/hive.py
@@ -45,6 +45,10 @@ from thrift.protocol import TBinaryProtocol
from thrift.transport import TSocket, TTransport
from pyiceberg.catalog import (
+ ICEBERG,
+ METADATA_LOCATION,
+ TABLE_TYPE,
+ WAREHOUSE_LOCATION,
Catalog,
Identifier,
Properties,
@@ -53,6 +57,7 @@ from pyiceberg.catalog import (
from pyiceberg.exceptions import (
NamespaceAlreadyExistsError,
NamespaceNotEmptyError,
+ NoSuchIcebergTableError,
NoSuchNamespaceError,
NoSuchTableError,
TableAlreadyExistsError,
@@ -104,11 +109,7 @@ hive_types = {
COMMENT = "comment"
OWNER = "owner"
-TABLE_TYPE = "table_type"
-METADATA_LOCATION = "metadata_location"
-ICEBERG = "iceberg"
LOCATION = "location"
-WAREHOUSE = "warehouse"
class _HiveClient:
@@ -246,7 +247,9 @@ class HiveCatalog(Catalog):
table_type = properties[TABLE_TYPE]
if table_type.lower() != ICEBERG:
- raise NoSuchTableError(f"Property table_type is {table_type},
expected {ICEBERG}: {table.dbName}.{table.tableName}")
+ raise NoSuchIcebergTableError(
+ f"Property table_type is {table_type}, expected {ICEBERG}:
{table.dbName}.{table.tableName}"
+ )
if prop_metadata_location := properties.get(METADATA_LOCATION):
metadata_location = prop_metadata_location
@@ -272,7 +275,7 @@ class HiveCatalog(Catalog):
database_location = database_location.rstrip("/")
return f"{database_location}/{table_name}"
- if warehouse_location := self.properties.get(WAREHOUSE):
+ if warehouse_location := self.properties.get(WAREHOUSE_LOCATION):
warehouse_location = warehouse_location.rstrip("/")
return f"{warehouse_location}/{database_name}/{table_name}"
raise ValueError("Cannot determine location from warehouse, please
provide an explicit location")