4949from pytest_lazy_fixtures import lf
5050
5151from pyiceberg .catalog import Catalog , load_catalog
52- from pyiceberg .catalog .bigquery_metastore import BigQueryMetastoreCatalog
53- from pyiceberg .catalog .dynamodb import DynamoDbCatalog
54- from pyiceberg .catalog .glue import GlueCatalog
55- from pyiceberg .catalog .hive import HiveCatalog
56- from pyiceberg .catalog .memory import InMemoryCatalog
57- from pyiceberg .catalog .noop import NoopCatalog
58- from pyiceberg .catalog .rest import RestCatalog
59- from pyiceberg .catalog .sql import SqlCatalog
6052from pyiceberg .expressions import BoundReference
6153from pyiceberg .io import (
6254 ADLS_ACCOUNT_KEY ,
@@ -2497,6 +2489,8 @@ def warehouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
24972489
24982490@pytest .fixture
24992491def table_v1 (example_table_metadata_v1 : dict [str , Any ]) -> Table :
2492+ from pyiceberg .catalog .noop import NoopCatalog
2493+
25002494 table_metadata = TableMetadataV1 (** example_table_metadata_v1 )
25012495 return Table (
25022496 identifier = ("database" , "table" ),
@@ -2509,6 +2503,8 @@ def table_v1(example_table_metadata_v1: dict[str, Any]) -> Table:
25092503
25102504@pytest .fixture
25112505def table_v2 (example_table_metadata_v2 : dict [str , Any ]) -> Table :
2506+ from pyiceberg .catalog .noop import NoopCatalog
2507+
25122508 table_metadata = TableMetadataV2 (** example_table_metadata_v2 )
25132509 return Table (
25142510 identifier = ("database" , "table" ),
@@ -2521,6 +2517,8 @@ def table_v2(example_table_metadata_v2: dict[str, Any]) -> Table:
25212517
25222518@pytest .fixture
25232519def table_v3 (example_table_metadata_v3 : dict [str , Any ]) -> Table :
2520+ from pyiceberg .catalog .noop import NoopCatalog
2521+
25242522 table_metadata = TableMetadataV3 (** example_table_metadata_v3 )
25252523 return Table (
25262524 identifier = ("database" , "table" ),
@@ -2535,6 +2533,8 @@ def table_v3(example_table_metadata_v3: dict[str, Any]) -> Table:
25352533def table_v2_orc (example_table_metadata_v2 : dict [str , Any ]) -> Table :
25362534 import copy
25372535
2536+ from pyiceberg .catalog .noop import NoopCatalog
2537+
25382538 metadata_dict = copy .deepcopy (example_table_metadata_v2 )
25392539 if not metadata_dict ["properties" ]:
25402540 metadata_dict ["properties" ] = {}
@@ -2553,6 +2553,8 @@ def table_v2_orc(example_table_metadata_v2: dict[str, Any]) -> Table:
25532553def table_v2_with_fixed_and_decimal_types (
25542554 table_metadata_v2_with_fixed_and_decimal_types : dict [str , Any ],
25552555) -> Table :
2556+ from pyiceberg .catalog .noop import NoopCatalog
2557+
25562558 table_metadata = TableMetadataV2 (
25572559 ** table_metadata_v2_with_fixed_and_decimal_types ,
25582560 )
@@ -2567,6 +2569,8 @@ def table_v2_with_fixed_and_decimal_types(
25672569
25682570@pytest .fixture
25692571def table_v2_with_extensive_snapshots (example_table_metadata_v2_with_extensive_snapshots : dict [str , Any ]) -> Table :
2572+ from pyiceberg .catalog .noop import NoopCatalog
2573+
25702574 table_metadata = TableMetadataV2 (** example_table_metadata_v2_with_extensive_snapshots )
25712575 return Table (
25722576 identifier = ("database" , "table" ),
@@ -2579,6 +2583,8 @@ def table_v2_with_extensive_snapshots(example_table_metadata_v2_with_extensive_s
25792583
25802584@pytest .fixture
25812585def table_v2_with_statistics (table_metadata_v2_with_statistics : dict [str , Any ]) -> Table :
2586+ from pyiceberg .catalog .noop import NoopCatalog
2587+
25822588 table_metadata = TableMetadataV2 (** table_metadata_v2_with_statistics )
25832589 return Table (
25842590 identifier = ("database" , "table" ),
@@ -3000,11 +3006,15 @@ def ray_session() -> Generator[Any, None, None]:
30003006# Catalog fixtures
30013007
30023008
3003- def _create_memory_catalog (name : str , warehouse : Path ) -> InMemoryCatalog :
3009+ def _create_memory_catalog (name : str , warehouse : Path ) -> Catalog :
3010+ from pyiceberg .catalog .memory import InMemoryCatalog
3011+
30043012 return InMemoryCatalog (name , warehouse = f"file://{ warehouse } " )
30053013
30063014
3007- def _create_sql_catalog (name : str , warehouse : Path ) -> SqlCatalog :
3015+ def _create_sql_catalog (name : str , warehouse : Path ) -> Catalog :
3016+ from pyiceberg .catalog .sql import SqlCatalog
3017+
30083018 catalog = SqlCatalog (
30093019 name ,
30103020 uri = "sqlite:///:memory:" ,
@@ -3014,7 +3024,9 @@ def _create_sql_catalog(name: str, warehouse: Path) -> SqlCatalog:
30143024 return catalog
30153025
30163026
3017- def _create_sql_without_rowcount_catalog (name : str , warehouse : Path ) -> SqlCatalog :
3027+ def _create_sql_without_rowcount_catalog (name : str , warehouse : Path ) -> Catalog :
3028+ from pyiceberg .catalog .sql import SqlCatalog
3029+
30183030 props = {
30193031 "uri" : f"sqlite:////{ warehouse } /sql-catalog" ,
30203032 "warehouse" : f"file://{ warehouse } " ,
@@ -3152,48 +3164,97 @@ def test_table_properties() -> dict[str, str]:
31523164
31533165
31543166def does_support_purge_table (catalog : Catalog ) -> bool :
3167+ from pyiceberg .catalog .noop import NoopCatalog
3168+ from pyiceberg .catalog .rest import RestCatalog
3169+
31553170 if isinstance (catalog , RestCatalog ):
31563171 return property_as_bool (catalog .properties , "supports_purge_table" , True )
3157- if isinstance (catalog , (HiveCatalog , NoopCatalog )):
3172+ from pyiceberg .catalog .hive import HiveCatalog
3173+
3174+ if isinstance (catalog , HiveCatalog ):
3175+ return False
3176+ if isinstance (catalog , NoopCatalog ):
31583177 return False
31593178 return True
31603179
31613180
31623181def does_support_atomic_concurrent_updates (catalog : Catalog ) -> bool :
3182+ from pyiceberg .catalog .noop import NoopCatalog
3183+ from pyiceberg .catalog .rest import RestCatalog
3184+
31633185 if isinstance (catalog , RestCatalog ):
31643186 return property_as_bool (catalog .properties , "supports_atomic_concurrent_updates" , True )
3165- if isinstance (catalog , (HiveCatalog , NoopCatalog )):
3187+ from pyiceberg .catalog .hive import HiveCatalog
3188+
3189+ if isinstance (catalog , HiveCatalog ):
3190+ return False
3191+ if isinstance (catalog , NoopCatalog ):
31663192 return False
31673193 return True
31683194
31693195
31703196def does_support_nested_namespaces (catalog : Catalog ) -> bool :
3197+ from pyiceberg .catalog .dynamodb import DynamoDbCatalog
3198+ from pyiceberg .catalog .glue import GlueCatalog
3199+ from pyiceberg .catalog .noop import NoopCatalog
3200+ from pyiceberg .catalog .rest import RestCatalog
3201+
31713202 if isinstance (catalog , RestCatalog ):
31723203 return property_as_bool (catalog .properties , "supports_nested_namespaces" , True )
3173- if isinstance (catalog , (HiveCatalog , NoopCatalog , GlueCatalog , BigQueryMetastoreCatalog , DynamoDbCatalog )):
3204+ from pyiceberg .catalog .bigquery_metastore import BigQueryMetastoreCatalog
3205+ from pyiceberg .catalog .hive import HiveCatalog
3206+
3207+ if isinstance (catalog , HiveCatalog ):
3208+ return False
3209+ if isinstance (catalog , BigQueryMetastoreCatalog ):
3210+ return False
3211+ if isinstance (catalog , (NoopCatalog , GlueCatalog , DynamoDbCatalog )):
31743212 return False
31753213 return True
31763214
31773215
31783216def does_support_schema_evolution (catalog : Catalog ) -> bool :
3217+ from pyiceberg .catalog .noop import NoopCatalog
3218+ from pyiceberg .catalog .rest import RestCatalog
3219+
31793220 if isinstance (catalog , RestCatalog ):
31803221 return property_as_bool (catalog .properties , "supports_schema_evolution" , True )
3181- if isinstance (catalog , (HiveCatalog , NoopCatalog )):
3222+ from pyiceberg .catalog .hive import HiveCatalog
3223+
3224+ if isinstance (catalog , HiveCatalog ):
3225+ return False
3226+ if isinstance (catalog , NoopCatalog ):
31823227 return False
31833228 return True
31843229
31853230
31863231def does_support_slash_in_identifier (catalog : Catalog ) -> bool :
3232+ from pyiceberg .catalog .noop import NoopCatalog
3233+ from pyiceberg .catalog .rest import RestCatalog
3234+ from pyiceberg .catalog .sql import SqlCatalog
3235+
31873236 if isinstance (catalog , RestCatalog ):
31883237 return property_as_bool (catalog .properties , "supports_slash_in_identifier" , True )
3189- if isinstance (catalog , (HiveCatalog , NoopCatalog , SqlCatalog )):
3238+ from pyiceberg .catalog .hive import HiveCatalog
3239+
3240+ if isinstance (catalog , HiveCatalog ):
3241+ return False
3242+ if isinstance (catalog , (NoopCatalog , SqlCatalog )):
31903243 return False
31913244 return True
31923245
31933246
31943247def does_support_dot_in_identifier (catalog : Catalog ) -> bool :
3248+ from pyiceberg .catalog .noop import NoopCatalog
3249+ from pyiceberg .catalog .rest import RestCatalog
3250+ from pyiceberg .catalog .sql import SqlCatalog
3251+
31953252 if isinstance (catalog , RestCatalog ):
31963253 return property_as_bool (catalog .properties , "supports_dot_in_identifier" , True )
3197- if isinstance (catalog , (HiveCatalog , NoopCatalog , SqlCatalog )):
3254+ from pyiceberg .catalog .hive import HiveCatalog
3255+
3256+ if isinstance (catalog , HiveCatalog ):
3257+ return False
3258+ if isinstance (catalog , (NoopCatalog , SqlCatalog )):
31983259 return False
31993260 return True
0 commit comments