From 2ac23aca0ad2e423a2e43c4eafb94b5e2e76cd19 Mon Sep 17 00:00:00 2001 From: HonahX Date: Sat, 13 Jan 2024 17:06:44 -0800 Subject: [PATCH] add test for glue catalog --- tests/catalog/integration_test_glue.py | 17 +++++++++++++++++ tests/catalog/test_glue.py | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/tests/catalog/integration_test_glue.py b/tests/catalog/integration_test_glue.py index 99f0adac40..24401cae39 100644 --- a/tests/catalog/integration_test_glue.py +++ b/tests/catalog/integration_test_glue.py @@ -294,3 +294,20 @@ def test_commit_table_update_schema( assert new_schema assert new_schema == update._apply() assert new_schema.find_field("b").field_type == IntegerType() + + +def test_commit_table_properties(test_catalog: Catalog, table_schema_nested: Schema, database_name: str, table_name: str) -> None: + identifier = (database_name, table_name) + test_catalog.create_namespace(namespace=database_name) + table = test_catalog.create_table(identifier=identifier, schema=table_schema_nested, properties={"test_a": "test_a"}) + + assert test_catalog._parse_metadata_version(table.metadata_location) == 0 + + transaction = table.transaction() + transaction.set_properties(test_a="test_aa", test_b="test_b", test_c="test_c") + transaction.remove_properties("test_b") + transaction.commit_transaction() + + updated_table_metadata = table.metadata + assert test_catalog._parse_metadata_version(table.metadata_location) == 1 + assert updated_table_metadata.properties == {"test_a": "test_aa", "test_c": "test_c"} diff --git a/tests/catalog/test_glue.py b/tests/catalog/test_glue.py index f84ed4ad20..bf6d11784f 100644 --- a/tests/catalog/test_glue.py +++ b/tests/catalog/test_glue.py @@ -553,3 +553,25 @@ def test_commit_table_update_schema( assert new_schema assert new_schema == update._apply() assert new_schema.find_field("b").field_type == IntegerType() + + +@mock_glue +def test_commit_table_properties( + _bucket_initialize: None, moto_endpoint_url: str, table_schema_nested: Schema, database_name: str, table_name: str +) -> None: + catalog_name = "glue" + identifier = (database_name, table_name) + test_catalog = GlueCatalog(catalog_name, **{"s3.endpoint": moto_endpoint_url, "warehouse": f"s3://{BUCKET_NAME}"}) + test_catalog.create_namespace(namespace=database_name) + table = test_catalog.create_table(identifier=identifier, schema=table_schema_nested, properties={"test_a": "test_a"}) + + assert test_catalog._parse_metadata_version(table.metadata_location) == 0 + + transaction = table.transaction() + transaction.set_properties(test_a="test_aa", test_b="test_b", test_c="test_c") + transaction.remove_properties("test_b") + transaction.commit_transaction() + + updated_table_metadata = table.metadata + assert test_catalog._parse_metadata_version(table.metadata_location) == 1 + assert updated_table_metadata.properties == {"test_a": "test_aa", "test_c": "test_c"}