Skip to content

Commit c6d2f11

Browse files
committed
moving away from public API
1 parent cb8f791 commit c6d2f11

File tree

10 files changed

+72
-127
lines changed

10 files changed

+72
-127
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -737,30 +737,6 @@ def namespace_to_string(identifier: str | Identifier, err: type[ValueError] | ty
737737
def supports_server_side_planning(self) -> bool:
738738
"""Check if the catalog supports server-side scan planning."""
739739

740-
@abstractmethod
741-
def supports_purge_table(self) -> bool:
742-
"""Check if the catalog supports purging tables."""
743-
744-
@abstractmethod
745-
def supports_atomic_concurrent_updates(self) -> bool:
746-
"""Check if the catalog supports atomic concurrent updates."""
747-
748-
@abstractmethod
749-
def supports_nested_namespaces(self) -> bool:
750-
"""Check if the catalog supports nested namespaces."""
751-
752-
@abstractmethod
753-
def supports_schema_evolution(self) -> bool:
754-
"""Check if the catalog supports schema evolution."""
755-
756-
@abstractmethod
757-
def supports_slash_in_identifier(self) -> bool:
758-
"""Check if the catalog supports slash in identifier."""
759-
760-
@abstractmethod
761-
def supports_dot_in_identifier(self) -> bool:
762-
"""Check if the catalog supports dot in identifier."""
763-
764740
@staticmethod
765741
def identifier_to_database(
766742
identifier: str | Identifier, err: type[ValueError] | type[NoSuchNamespaceError] = ValueError
@@ -863,24 +839,6 @@ def __init__(self, name: str, **properties: str):
863839
def supports_server_side_planning(self) -> bool:
864840
return False
865841

866-
def supports_purge_table(self) -> bool:
867-
return True
868-
869-
def supports_atomic_concurrent_updates(self) -> bool:
870-
return True
871-
872-
def supports_nested_namespaces(self) -> bool:
873-
return True
874-
875-
def supports_schema_evolution(self) -> bool:
876-
return True
877-
878-
def supports_slash_in_identifier(self) -> bool:
879-
return True
880-
881-
def supports_dot_in_identifier(self) -> bool:
882-
return True
883-
884842
def create_table_transaction(
885843
self,
886844
identifier: str | Identifier,

pyiceberg/catalog/bigquery_metastore.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ def __init__(self, name: str, **properties: str):
9898
self.location = location
9999
self.project_id = project_id
100100

101-
def supports_nested_namespaces(self) -> bool:
102-
return False
103-
104101
def create_table(
105102
self,
106103
identifier: str | Identifier,

pyiceberg/catalog/dynamodb.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ def __init__(self, name: str, client: Optional["DynamoDBClient"] = None, **prope
117117
self.dynamodb_table_name = self.properties.get(DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT)
118118
self._ensure_catalog_table_exists_or_create()
119119

120-
def supports_nested_namespaces(self) -> bool:
121-
return False
122-
123120
def _ensure_catalog_table_exists_or_create(self) -> None:
124121
if self._dynamodb_table_exists():
125122
return None

pyiceberg/catalog/glue.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ def __init__(self, name: str, client: Optional["GlueClient"] = None, **propertie
350350
if glue_catalog_id := properties.get(GLUE_ID):
351351
_register_glue_catalog_id_with_glue_client(self.glue, glue_catalog_id)
352352

353-
def supports_nested_namespaces(self) -> bool:
354-
return False
355-
356353
def _convert_glue_to_iceberg(self, glue_table: "TableTypeDef") -> Table:
357354
if (database_name := glue_table.get("DatabaseName")) is None:
358355
raise ValueError("Glue table is missing DatabaseName property")

pyiceberg/catalog/hive.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -650,24 +650,6 @@ def drop_table(self, identifier: str | Identifier) -> None:
650650
# When the namespace doesn't exist, it throws the same error
651651
raise NoSuchTableError(f"Table does not exists: {table_name}") from e
652652

653-
def supports_purge_table(self) -> bool:
654-
return False
655-
656-
def supports_atomic_concurrent_updates(self) -> bool:
657-
return False
658-
659-
def supports_nested_namespaces(self) -> bool:
660-
return False
661-
662-
def supports_schema_evolution(self) -> bool:
663-
return False
664-
665-
def supports_slash_in_identifier(self) -> bool:
666-
return False
667-
668-
def supports_dot_in_identifier(self) -> bool:
669-
return False
670-
671653
def purge_table(self, identifier: str | Identifier) -> None:
672654
# This requires to traverse the reachability set, and drop all the data files.
673655
raise NotImplementedError("Not yet implemented")

pyiceberg/catalog/noop.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,6 @@ def drop_table(self, identifier: str | Identifier) -> None:
8888
def supports_server_side_planning(self) -> bool:
8989
raise NotImplementedError
9090

91-
def supports_purge_table(self) -> bool:
92-
raise NotImplementedError
93-
94-
def supports_atomic_concurrent_updates(self) -> bool:
95-
raise NotImplementedError
96-
97-
def supports_nested_namespaces(self) -> bool:
98-
raise NotImplementedError
99-
100-
def supports_schema_evolution(self) -> bool:
101-
raise NotImplementedError
102-
103-
def supports_slash_in_identifier(self) -> bool:
104-
raise NotImplementedError
105-
106-
def supports_dot_in_identifier(self) -> bool:
107-
raise NotImplementedError
108-
10991
def purge_table(self, identifier: str | Identifier) -> None:
11092
raise NotImplementedError
11193

pyiceberg/catalog/rest/__init__.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -403,30 +403,6 @@ def supports_server_side_planning(self) -> bool:
403403
self.properties, REST_SCAN_PLANNING_ENABLED, REST_SCAN_PLANNING_ENABLED_DEFAULT
404404
)
405405

406-
def supports_purge_table(self) -> bool:
407-
"""Check if the catalog supports purging tables."""
408-
return property_as_bool(self.properties, "supports_purge_table", True)
409-
410-
def supports_atomic_concurrent_updates(self) -> bool:
411-
"""Check if the catalog supports atomic concurrent updates."""
412-
return property_as_bool(self.properties, "supports_atomic_concurrent_updates", True)
413-
414-
def supports_nested_namespaces(self) -> bool:
415-
"""Check if the catalog supports nested namespaces."""
416-
return property_as_bool(self.properties, "supports_nested_namespaces", True)
417-
418-
def supports_schema_evolution(self) -> bool:
419-
"""Check if the catalog supports schema evolution."""
420-
return property_as_bool(self.properties, "supports_schema_evolution", True)
421-
422-
def supports_slash_in_identifier(self) -> bool:
423-
"""Check if the catalog supports slash in identifier."""
424-
return property_as_bool(self.properties, "supports_slash_in_identifier", True)
425-
426-
def supports_dot_in_identifier(self) -> bool:
427-
"""Check if the catalog supports dot in identifier."""
428-
return property_as_bool(self.properties, "supports_dot_in_identifier", True)
429-
430406
@retry(**_RETRY_ARGS)
431407
def _plan_table_scan(self, identifier: str | Identifier, request: PlanTableScanRequest) -> PlanningResponse:
432408
"""Submit a scan plan request to the REST server.

pyiceberg/catalog/sql.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ def create_tables(self) -> None:
149149
def destroy_tables(self) -> None:
150150
SqlCatalogBaseTable.metadata.drop_all(self.engine)
151151

152-
def supports_slash_in_identifier(self) -> bool:
153-
return False
154-
155-
def supports_dot_in_identifier(self) -> bool:
156-
return False
157-
158152
def _convert_orm_to_iceberg(self, orm_table: IcebergTables) -> Table:
159153
# Check for expected properties.
160154
if not (metadata_location := orm_table.metadata_location):

tests/conftest.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@
4848
from pytest_lazyfixture import lazy_fixture
4949

5050
from pyiceberg.catalog import Catalog, load_catalog
51+
from pyiceberg.catalog.bigquery_metastore import BigQueryMetastoreCatalog
52+
from pyiceberg.catalog.dynamodb import DynamoDbCatalog
53+
from pyiceberg.catalog.glue import GlueCatalog
54+
from pyiceberg.catalog.hive import HiveCatalog
5155
from pyiceberg.catalog.memory import InMemoryCatalog
5256
from pyiceberg.catalog.noop import NoopCatalog
57+
from pyiceberg.catalog.rest import RestCatalog
5358
from pyiceberg.catalog.sql import SqlCatalog
5459
from pyiceberg.expressions import BoundReference
5560
from pyiceberg.io import (
@@ -97,6 +102,7 @@
97102
UUIDType,
98103
)
99104
from pyiceberg.utils.datetime import datetime_to_millis
105+
from pyiceberg.utils.properties import property_as_bool
100106

101107
if TYPE_CHECKING:
102108
import pyarrow as pa
@@ -3130,3 +3136,51 @@ def test_table_properties() -> dict[str, str]:
31303136
"key1": "value1",
31313137
"key2": "value2",
31323138
}
3139+
3140+
3141+
def does_support_purge_table(catalog: Catalog) -> bool:
3142+
if isinstance(catalog, RestCatalog):
3143+
return property_as_bool(catalog.properties, "supports_purge_table", True)
3144+
if isinstance(catalog, (HiveCatalog, NoopCatalog)):
3145+
return False
3146+
return True
3147+
3148+
3149+
def does_support_atomic_concurrent_updates(catalog: Catalog) -> bool:
3150+
if isinstance(catalog, RestCatalog):
3151+
return property_as_bool(catalog.properties, "supports_atomic_concurrent_updates", True)
3152+
if isinstance(catalog, (HiveCatalog, NoopCatalog)):
3153+
return False
3154+
return True
3155+
3156+
3157+
def does_support_nested_namespaces(catalog: Catalog) -> bool:
3158+
if isinstance(catalog, RestCatalog):
3159+
return property_as_bool(catalog.properties, "supports_nested_namespaces", True)
3160+
if isinstance(catalog, (HiveCatalog, NoopCatalog, GlueCatalog, BigQueryMetastoreCatalog, DynamoDbCatalog)):
3161+
return False
3162+
return True
3163+
3164+
3165+
def does_support_schema_evolution(catalog: Catalog) -> bool:
3166+
if isinstance(catalog, RestCatalog):
3167+
return property_as_bool(catalog.properties, "supports_schema_evolution", True)
3168+
if isinstance(catalog, (HiveCatalog, NoopCatalog)):
3169+
return False
3170+
return True
3171+
3172+
3173+
def does_support_slash_in_identifier(catalog: Catalog) -> bool:
3174+
if isinstance(catalog, RestCatalog):
3175+
return property_as_bool(catalog.properties, "supports_slash_in_identifier", True)
3176+
if isinstance(catalog, (HiveCatalog, NoopCatalog, SqlCatalog)):
3177+
return False
3178+
return True
3179+
3180+
3181+
def does_support_dot_in_identifier(catalog: Catalog) -> bool:
3182+
if isinstance(catalog, RestCatalog):
3183+
return property_as_bool(catalog.properties, "supports_dot_in_identifier", True)
3184+
if isinstance(catalog, (HiveCatalog, NoopCatalog, SqlCatalog)):
3185+
return False
3186+
return True

tests/integration/test_catalog.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@
4343
from pyiceberg.table.sorting import INITIAL_SORT_ORDER_ID, SortField, SortOrder
4444
from pyiceberg.transforms import BucketTransform, DayTransform, IdentityTransform
4545
from pyiceberg.types import IntegerType, LongType, NestedField, TimestampType, UUIDType
46-
from tests.conftest import clean_up
46+
from tests.conftest import (
47+
clean_up,
48+
does_support_atomic_concurrent_updates,
49+
does_support_dot_in_identifier,
50+
does_support_nested_namespaces,
51+
does_support_purge_table,
52+
does_support_schema_evolution,
53+
does_support_slash_in_identifier,
54+
)
4755

4856

4957
@pytest.fixture(scope="function")
@@ -246,7 +254,7 @@ def test_drop_table(test_catalog: Catalog, table_schema_nested: Schema, table_na
246254
@pytest.mark.integration
247255
@pytest.mark.parametrize("test_catalog", CATALOGS)
248256
def test_purge_table(test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str) -> None:
249-
if not test_catalog.supports_purge_table():
257+
if not does_support_purge_table(test_catalog):
250258
pytest.skip("Catalog does not support purge_table operation")
251259

252260
identifier = (database_name, table_name)
@@ -299,7 +307,7 @@ def test_update_table_transaction(test_catalog: Catalog, test_schema: Schema, ta
299307
@pytest.mark.integration
300308
@pytest.mark.parametrize("test_catalog", CATALOGS)
301309
def test_update_schema_conflict(test_catalog: Catalog, test_schema: Schema, table_name: str, database_name: str) -> None:
302-
if not test_catalog.supports_atomic_concurrent_updates():
310+
if not does_support_atomic_concurrent_updates(test_catalog):
303311
pytest.skip("Catalog does not support atomic concurrent updates")
304312

305313
identifier = (database_name, table_name)
@@ -646,7 +654,7 @@ def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema
646654
def test_incompatible_partitioned_schema_evolution(
647655
test_catalog: Catalog, test_schema: Schema, test_partition_spec: PartitionSpec, database_name: str, table_name: str
648656
) -> None:
649-
if not test_catalog.supports_schema_evolution():
657+
if not does_support_schema_evolution(test_catalog):
650658
pytest.skip(f"{type(test_catalog).__name__} does not support schema evolution")
651659

652660
identifier = (database_name, table_name)
@@ -675,7 +683,7 @@ def test_incompatible_partitioned_schema_evolution(
675683
@pytest.mark.integration
676684
@pytest.mark.parametrize("test_catalog", CATALOGS)
677685
def test_namespace_with_slash(test_catalog: Catalog) -> None:
678-
if not test_catalog.supports_slash_in_identifier():
686+
if not does_support_slash_in_identifier(test_catalog):
679687
pytest.skip(f"{type(test_catalog).__name__} does not support slash in namespace")
680688

681689
namespace = ("new/db",)
@@ -700,7 +708,7 @@ def test_namespace_with_slash(test_catalog: Catalog) -> None:
700708
def test_incompatible_sorted_schema_evolution(
701709
test_catalog: Catalog, test_schema: Schema, test_sort_order: SortOrder, database_name: str, table_name: str
702710
) -> None:
703-
if not test_catalog.supports_schema_evolution():
711+
if not does_support_schema_evolution(test_catalog):
704712
pytest.skip(f"{type(test_catalog).__name__} does not support schema evolution")
705713

706714
identifier = (database_name, table_name)
@@ -720,7 +728,7 @@ def test_incompatible_sorted_schema_evolution(
720728
@pytest.mark.integration
721729
@pytest.mark.parametrize("test_catalog", CATALOGS)
722730
def test_namespace_with_dot(test_catalog: Catalog) -> None:
723-
if not test_catalog.supports_dot_in_identifier():
731+
if not does_support_dot_in_identifier(test_catalog):
724732
pytest.skip(f"{type(test_catalog).__name__} does not support dot in namespace")
725733

726734
namespace = ("new.db",)
@@ -734,7 +742,7 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
734742
assert test_catalog.namespace_exists(namespace)
735743

736744
# Hierarchical catalogs might treat this as multiple levels.
737-
if test_catalog.supports_nested_namespaces():
745+
if does_support_nested_namespaces(test_catalog):
738746
namespaces = test_catalog.list_namespaces()
739747
assert ("new",) in namespaces or ("new.db",) in namespaces
740748
else:
@@ -750,7 +758,7 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
750758
@pytest.mark.integration
751759
@pytest.mark.parametrize("test_catalog", CATALOGS)
752760
def test_table_name_with_slash(test_catalog: Catalog, table_schema_simple: Schema) -> None:
753-
if not test_catalog.supports_slash_in_identifier():
761+
if not does_support_slash_in_identifier(test_catalog):
754762
pytest.skip(f"{type(test_catalog).__name__} does not support slash in table name")
755763

756764
namespace = ("ns_slash",)
@@ -777,7 +785,7 @@ def test_table_name_with_slash(test_catalog: Catalog, table_schema_simple: Schem
777785
@pytest.mark.integration
778786
@pytest.mark.parametrize("test_catalog", CATALOGS)
779787
def test_table_name_with_dot(test_catalog: Catalog, table_schema_simple: Schema) -> None:
780-
if not test_catalog.supports_dot_in_identifier():
788+
if not does_support_dot_in_identifier(test_catalog):
781789
pytest.skip(f"{type(test_catalog).__name__} does not support dot in table name")
782790

783791
namespace = ("ns_dot",)

0 commit comments

Comments
 (0)