You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by gi...@apache.org on 2026/10/23 07:03:13 UTC

(iceberg-python) branch gh-readonly-queue/main/pr-4133-e3fbd9440ad0bb25c45848797ff9ec5ad7758624 created (now b86b4431f)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-4133-e3fbd9440ad0bb25c45848797ff9ec5ad7758624
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


      at b86b4431f Glue: Prune removed table properties from Glue Parameters (#4133)

This branch includes the following new commits:

     new b86b4431f Glue: Prune removed table properties from Glue Parameters (#4133)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(iceberg-python) 01/01: Glue: Prune removed table properties from Glue Parameters (#4133)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-4133-e3fbd9440ad0bb25c45848797ff9ec5ad7758624
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git

commit b86b4431f29203ac94b0b2903f9fcc67d5d7b989
Author: Ankit Raj <an...@gmail.com>
AuthorDate: Thu Oct 22 23:13:43 2026 +0000

    Glue: Prune removed table properties from Glue Parameters (#4133)
    
    * Glue: Prune removed table properties from Glue Parameters
    
    Closes #3977
    
    * Use keyword arguments for _construct_parameters
---
 pyiceberg/catalog/glue.py  | 15 ++++++++++++++-
 tests/catalog/test_glue.py | 30 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/pyiceberg/catalog/glue.py b/pyiceberg/catalog/glue.py
index 977876918..a2cc6821a 100644
--- a/pyiceberg/catalog/glue.py
+++ b/pyiceberg/catalog/glue.py
@@ -147,8 +147,13 @@ def _construct_parameters(
     glue_table: Optional["TableTypeDef"] = None,
     prev_metadata_location: str | None = None,
     metadata_properties: Properties | None = None,
+    prev_metadata_properties: Properties | None = None,
 ) -> Properties:
     new_parameters = glue_table.get("Parameters", {}) if glue_table else {}
+    if prev_metadata_properties:
+        for key in prev_metadata_properties:
+            if not metadata_properties or key not in metadata_properties:
+                new_parameters.pop(key, None)
     new_parameters.update({TABLE_TYPE: ICEBERG.upper(), METADATA_LOCATION: metadata_location})
     if prev_metadata_location:
         new_parameters[PREVIOUS_METADATA_LOCATION] = prev_metadata_location
@@ -243,11 +248,18 @@ def _construct_table_input(
     metadata: TableMetadata,
     glue_table: Optional["TableTypeDef"] = None,
     prev_metadata_location: str | None = None,
+    prev_metadata_properties: Properties | None = None,
 ) -> "TableInputTypeDef":
     table_input: TableInputTypeDef = {
         "Name": table_name,
         "TableType": EXTERNAL_TABLE,
-        "Parameters": _construct_parameters(metadata_location, glue_table, prev_metadata_location, properties),
+        "Parameters": _construct_parameters(
+            metadata_location=metadata_location,
+            glue_table=glue_table,
+            prev_metadata_location=prev_metadata_location,
+            metadata_properties=properties,
+            prev_metadata_properties=prev_metadata_properties,
+        ),
         "StorageDescriptor": {
             "Columns": _to_columns(metadata),
             "Location": metadata.location,
@@ -693,6 +705,7 @@ class GlueCatalog(MetastoreCatalog):
                 metadata=updated_staged_table.metadata,
                 glue_table=current_glue_table,
                 prev_metadata_location=current_table.metadata_location,
+                prev_metadata_properties=current_table.properties,
             )
             self._update_glue_table(
                 database_name=database_name,
diff --git a/tests/catalog/test_glue.py b/tests/catalog/test_glue.py
index fd476c978..5b7beb7bd 100644
--- a/tests/catalog/test_glue.py
+++ b/tests/catalog/test_glue.py
@@ -859,6 +859,36 @@ def test_commit_table_properties(
     assert table_info["Table"]["Parameters"]["test_c"] == "test_c"
 
 
+@mock_aws
+def test_commit_table_prunes_removed_properties(
+    _glue: boto3.client,
+    _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, client=None, **{"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", "test_b": "test_b"}
+    )
+
+    transaction = table.transaction()
+    transaction.remove_properties("test_b")
+    transaction.commit_transaction()
+
+    assert table.metadata.properties == {"test_a": "test_a"}
+
+    table_info = _glue.get_table(DatabaseName=database_name, Name=table_name)
+    assert table_info["Table"]["Parameters"]["test_a"] == "test_a"
+    assert "test_b" not in table_info["Table"]["Parameters"]
+
+
 @mock_aws
 def test_commit_append_table_snapshot_properties(
     _bucket_initialize: None, moto_endpoint_url: str, table_schema_simple: Schema, database_name: str, table_name: str