4444from pyiceberg .table .sorting import INITIAL_SORT_ORDER_ID , SortField , SortOrder
4545from pyiceberg .transforms import BucketTransform , DayTransform , IdentityTransform
4646from pyiceberg .types import IntegerType , LongType , NestedField , TimestampType , UUIDType
47- from tests .conftest import clean_up
47+ from tests .conftest import (
48+ clean_up ,
49+ does_support_atomic_concurrent_updates ,
50+ does_support_dot_in_identifier ,
51+ does_support_nested_namespaces ,
52+ does_support_purge_table ,
53+ does_support_schema_evolution ,
54+ does_support_slash_in_identifier ,
55+ )
4856
4957
5058@pytest .fixture (scope = "function" )
@@ -247,8 +255,8 @@ def test_drop_table(test_catalog: Catalog, table_schema_nested: Schema, table_na
247255@pytest .mark .integration
248256@pytest .mark .parametrize ("test_catalog" , CATALOGS )
249257def test_purge_table (test_catalog : Catalog , table_schema_nested : Schema , table_name : str , database_name : str ) -> None :
250- if isinstance (test_catalog , HiveCatalog ):
251- pytest .skip ("HiveCatalog does not support purge_table operation yet " )
258+ if not does_support_purge_table (test_catalog ):
259+ pytest .skip ("Catalog does not support purge_table operation" )
252260
253261 identifier = (database_name , table_name )
254262 test_catalog .create_namespace (database_name )
@@ -300,8 +308,8 @@ def test_update_table_transaction(test_catalog: Catalog, test_schema: Schema, ta
300308@pytest .mark .integration
301309@pytest .mark .parametrize ("test_catalog" , CATALOGS )
302310def test_update_schema_conflict (test_catalog : Catalog , test_schema : Schema , table_name : str , database_name : str ) -> None :
303- if isinstance (test_catalog , HiveCatalog ):
304- pytest .skip ("HiveCatalog fails in this test, need to investigate " )
311+ if not does_support_atomic_concurrent_updates (test_catalog ):
312+ pytest .skip ("Catalog does not support atomic concurrent updates " )
305313
306314 identifier = (database_name , table_name )
307315
@@ -647,8 +655,8 @@ def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema
647655def test_incompatible_partitioned_schema_evolution (
648656 test_catalog : Catalog , test_schema : Schema , test_partition_spec : PartitionSpec , database_name : str , table_name : str
649657) -> None :
650- if isinstance (test_catalog , HiveCatalog ):
651- pytest .skip ("HiveCatalog does not support schema evolution" )
658+ if not does_support_schema_evolution (test_catalog ):
659+ pytest .skip (f" { type ( test_catalog ). __name__ } does not support schema evolution" )
652660
653661 identifier = (database_name , table_name )
654662 test_catalog .create_namespace (database_name )
@@ -676,7 +684,7 @@ def test_incompatible_partitioned_schema_evolution(
676684@pytest .mark .integration
677685@pytest .mark .parametrize ("test_catalog" , CATALOGS )
678686def test_namespace_with_slash (test_catalog : Catalog ) -> None :
679- if isinstance (test_catalog , HiveCatalog ):
687+ if not does_support_slash_in_identifier (test_catalog ):
680688 pytest .skip (f"{ type (test_catalog ).__name__ } does not support slash in namespace" )
681689
682690 namespace = ("new/db" ,)
@@ -701,8 +709,8 @@ def test_namespace_with_slash(test_catalog: Catalog) -> None:
701709def test_incompatible_sorted_schema_evolution (
702710 test_catalog : Catalog , test_schema : Schema , test_sort_order : SortOrder , database_name : str , table_name : str
703711) -> None :
704- if isinstance (test_catalog , HiveCatalog ):
705- pytest .skip ("HiveCatalog does not support schema evolution" )
712+ if not does_support_schema_evolution (test_catalog ):
713+ pytest .skip (f" { type ( test_catalog ). __name__ } does not support schema evolution" )
706714
707715 identifier = (database_name , table_name )
708716 test_catalog .create_namespace (database_name )
@@ -721,7 +729,7 @@ def test_incompatible_sorted_schema_evolution(
721729@pytest .mark .integration
722730@pytest .mark .parametrize ("test_catalog" , CATALOGS )
723731def test_namespace_with_dot (test_catalog : Catalog ) -> None :
724- if isinstance ( test_catalog , ( HiveCatalog , SqlCatalog ) ):
732+ if not does_support_dot_in_identifier ( test_catalog ):
725733 pytest .skip (f"{ type (test_catalog ).__name__ } does not support dot in namespace" )
726734
727735 namespace = ("new.db" ,)
@@ -734,9 +742,8 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
734742 test_catalog .create_namespace (namespace )
735743 assert test_catalog .namespace_exists (namespace )
736744
737- # REST Catalog fixture treats this as a hierarchical namespace.
738- # Calling list namespaces will get `new`, not `new.db`.
739- if isinstance (test_catalog , RestCatalog ):
745+ # Hierarchical catalogs might treat this as multiple levels.
746+ if does_support_nested_namespaces (test_catalog ):
740747 namespaces = test_catalog .list_namespaces ()
741748 assert ("new" ,) in namespaces or ("new.db" ,) in namespaces
742749 else :
@@ -752,7 +759,7 @@ def test_namespace_with_dot(test_catalog: Catalog) -> None:
752759@pytest .mark .integration
753760@pytest .mark .parametrize ("test_catalog" , CATALOGS )
754761def test_table_name_with_slash (test_catalog : Catalog , table_schema_simple : Schema ) -> None :
755- if isinstance ( test_catalog , ( HiveCatalog , SqlCatalog ) ):
762+ if not does_support_slash_in_identifier ( test_catalog ):
756763 pytest .skip (f"{ type (test_catalog ).__name__ } does not support slash in table name" )
757764
758765 namespace = ("ns_slash" ,)
@@ -779,7 +786,7 @@ def test_table_name_with_slash(test_catalog: Catalog, table_schema_simple: Schem
779786@pytest .mark .integration
780787@pytest .mark .parametrize ("test_catalog" , CATALOGS )
781788def test_table_name_with_dot (test_catalog : Catalog , table_schema_simple : Schema ) -> None :
782- if isinstance ( test_catalog , ( HiveCatalog , SqlCatalog ) ):
789+ if not does_support_dot_in_identifier ( test_catalog ):
783790 pytest .skip (f"{ type (test_catalog ).__name__ } does not support dot in table name" )
784791
785792 namespace = ("ns_dot" ,)
@@ -818,9 +825,6 @@ def test_drop_missing_table(test_catalog: Catalog, database_name: str) -> None:
818825@pytest .mark .integration
819826@pytest .mark .parametrize ("test_catalog" , CATALOGS )
820827def test_drop_nonexistent_namespace (test_catalog : Catalog ) -> None :
821- if isinstance (test_catalog , HiveCatalog ):
822- pytest .skip ("HiveCatalog raises NoSuchObjectException instead of NoSuchNamespaceError" )
823-
824828 namespace = ("non_existent_namespace" ,)
825829 with pytest .raises (NoSuchNamespaceError ):
826830 test_catalog .drop_namespace (namespace )
0 commit comments