Skip to content

Commit 0489659

Browse files
committed
Catalog test fixes
1 parent dc94569 commit 0489659

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def _create_table(
790790
if location:
791791
location = location.rstrip("/")
792792
request = CreateTableRequest(
793-
name=namespace_and_table["table"],
793+
name=self._identifier_to_validated_tuple(identifier)[-1],
794794
location=location,
795795
table_schema=fresh_schema,
796796
partition_spec=fresh_partition_spec,
@@ -869,7 +869,7 @@ def register_table(self, identifier: str | Identifier, metadata_location: str) -
869869
self._check_endpoint(Capability.V1_REGISTER_TABLE)
870870
namespace_and_table = self._split_identifier_for_path(identifier)
871871
request = RegisterTableRequest(
872-
name=namespace_and_table["table"],
872+
name=self._identifier_to_validated_tuple(identifier)[-1],
873873
metadata_location=metadata_location,
874874
)
875875
serialized_json = request.model_dump_json().encode(UTF8)

tests/integration/test_catalog.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema
637637
loaded_table = rest_catalog.load_table(identifier=full_table_identifier_tuple)
638638
assert loaded_table.name() == full_table_identifier_tuple
639639

640+
640641
def _namespace_exists(catalog: Catalog, namespace: str | Identifier) -> bool:
641642
try:
642643
catalog.load_namespace_properties(namespace)
@@ -648,7 +649,7 @@ def _namespace_exists(catalog: Catalog, namespace: str | Identifier) -> bool:
648649
@pytest.mark.integration
649650
@pytest.mark.parametrize("test_catalog", CATALOGS)
650651
def test_namespace_with_slash(test_catalog: Catalog) -> None:
651-
if isinstance(test_catalog, (HiveCatalog, SqlCatalog, RestCatalog)):
652+
if isinstance(test_catalog, HiveCatalog):
652653
pytest.skip(f"{type(test_catalog).__name__} does not support slash in namespace")
653654

654655
namespace = ("new/db",)
@@ -671,7 +672,7 @@ def test_namespace_with_slash(test_catalog: Catalog) -> None:
671672
@pytest.mark.integration
672673
@pytest.mark.parametrize("test_catalog", CATALOGS)
673674
def test_namespace_with_dot(test_catalog: Catalog) -> None:
674-
if isinstance(test_catalog, (HiveCatalog, SqlCatalog, RestCatalog)):
675+
if isinstance(test_catalog, (HiveCatalog, SqlCatalog)):
675676
pytest.skip(f"{type(test_catalog).__name__} does not support dot in namespace")
676677

677678
namespace = ("new.db",)
@@ -685,7 +686,11 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
685686
assert _namespace_exists(test_catalog, namespace)
686687

687688
# list_namespaces returns a list of tuples
688-
assert namespace in test_catalog.list_namespaces()
689+
if isinstance(test_catalog, RestCatalog):
690+
namespaces = test_catalog.list_namespaces()
691+
assert ("new",) in namespaces or ("new.db",) in namespaces
692+
else:
693+
assert namespace in test_catalog.list_namespaces()
689694

690695
properties = test_catalog.load_namespace_properties(namespace)
691696
assert properties is not None
@@ -697,7 +702,7 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
697702
@pytest.mark.integration
698703
@pytest.mark.parametrize("test_catalog", CATALOGS)
699704
def test_table_name_with_slash(test_catalog: Catalog, table_schema_simple: Schema) -> None:
700-
if isinstance(test_catalog, (HiveCatalog, SqlCatalog, RestCatalog)):
705+
if isinstance(test_catalog, (HiveCatalog, SqlCatalog)):
701706
pytest.skip(f"{type(test_catalog).__name__} does not support slash in table name")
702707

703708
namespace = ("ns_slash",)
@@ -724,7 +729,7 @@ def test_table_name_with_slash(test_catalog: Catalog, table_schema_simple: Schem
724729
@pytest.mark.integration
725730
@pytest.mark.parametrize("test_catalog", CATALOGS)
726731
def test_table_name_with_dot(test_catalog: Catalog, table_schema_simple: Schema) -> None:
727-
if isinstance(test_catalog, (HiveCatalog, SqlCatalog, RestCatalog)):
732+
if isinstance(test_catalog, (HiveCatalog, SqlCatalog)):
728733
pytest.skip(f"{type(test_catalog).__name__} does not support dot in table name")
729734

730735
namespace = ("ns_dot",)

0 commit comments

Comments
 (0)