Skip to content

Commit 769536b

Browse files
committed
mostly fix hive?
1 parent 2bb2229 commit 769536b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,13 +2318,19 @@ def fixture_s3_client() -> boto3.client:
23182318
yield boto3.client("s3")
23192319

23202320

2321-
def clean_up(test_catalog: Catalog) -> None:
2321+
def clean_up(test_catalog: Catalog, drop_if_cannot_purge: bool = False) -> None:
23222322
"""Clean all databases and tables created during the integration test."""
23232323
for database_tuple in test_catalog.list_namespaces():
23242324
database_name = database_tuple[0]
23252325
if "my_iceberg_database-" in database_name:
23262326
for identifier in test_catalog.list_tables(database_name):
2327-
test_catalog.purge_table(identifier)
2327+
try:
2328+
test_catalog.purge_table(identifier)
2329+
except Exception as e:
2330+
if drop_if_cannot_purge:
2331+
test_catalog.drop_table(identifier)
2332+
else:
2333+
raise e
23282334
test_catalog.drop_namespace(database_name)
23292335

23302336

tests/integration/test_catalog.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
from pyiceberg.schema import Schema
3737
from tests.conftest import clean_up
3838

39-
# The number of tables/databases used in list_table/namespace test
40-
LIST_TEST_NUMBER = 2
41-
4239

4340
@pytest.fixture(scope="function")
4441
def memory_catalog(tmp_path: PosixPath) -> Generator[Catalog, None, None]:
@@ -81,10 +78,15 @@ def rest_catalog() -> Generator[Catalog, None, None]:
8178
def hive_catalog() -> Generator[Catalog, None, None]:
8279
test_catalog = HiveCatalog(
8380
"test_hive_catalog",
84-
uri="thrift://localhost:9083",
81+
**{
82+
"uri": "http://localhost:9083",
83+
"s3.endpoint": "http://localhost:9000",
84+
"s3.access-key-id": "admin",
85+
"s3.secret-access-key": "password",
86+
},
8587
)
8688
yield test_catalog
87-
clean_up(test_catalog)
89+
clean_up(test_catalog, drop_if_cannot_purge=True)
8890

8991

9092
@pytest.mark.integration
@@ -201,7 +203,7 @@ def test_list_tables(test_catalog: Catalog, table_schema_nested: Schema, databas
201203
for table_name in table_list:
202204
test_catalog.create_table((database_name, table_name), table_schema_nested)
203205
identifier_list = test_catalog.list_tables(database_name)
204-
assert len(identifier_list) == LIST_TEST_NUMBER
206+
assert len(identifier_list) == len(table_list)
205207
for table_name in table_list:
206208
assert (database_name, table_name) in identifier_list
207209

@@ -263,7 +265,7 @@ def test_drop_table(test_catalog: Catalog, table_schema_nested: Schema, table_na
263265
pytest.lazy_fixture("sqlite_catalog_memory"),
264266
pytest.lazy_fixture("sqlite_catalog_file"),
265267
pytest.lazy_fixture("rest_catalog"),
266-
pytest.lazy_fixture("hive_catalog"),
268+
# NOTE: HiveCatalog does not support purge_table
267269
],
268270
)
269271
def test_purge_table(test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str) -> None:

0 commit comments

Comments
 (0)