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

kevinjqliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 0f10a972 fix:update config during table refresh (#3327)
0f10a972 is described below

commit 0f10a97261c6c7e97a18f2bfeade7f48f70e6036
Author: Yingjian Wu <[email protected]>
AuthorDate: Wed May 6 10:33:50 2026 -0700

    fix:update config during table refresh (#3327)
    
    # Rationale for this change
    Table.refresh() was not updating self.config from the refreshed
    TableResponse. The config field contains out of date, server-generated
    properties such as per-table access tokens (token) and credential
    refresh endpoints(client.refresh-credentials-endpoint).
    
    ## Are these changes tested?
    Yes, with a new test.
    
    ## Are there any user-facing changes?
    No
    
    Co-authored-by: Yingjian Wu <[email protected]>
---
 pyiceberg/table/__init__.py |  1 +
 tests/catalog/test_rest.py  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py
index 7f152464..b8d87143 100644
--- a/pyiceberg/table/__init__.py
+++ b/pyiceberg/table/__init__.py
@@ -1103,6 +1103,7 @@ class Table:
         self.metadata = fresh.metadata
         self.io = fresh.io
         self.metadata_location = fresh.metadata_location
+        self.config = fresh.config
         return self
 
     def name(self) -> Identifier:
diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py
index 79778926..e61274ba 100644
--- a/tests/catalog/test_rest.py
+++ b/tests/catalog/test_rest.py
@@ -2535,6 +2535,39 @@ def test_table_uuid_check_on_commit(rest_mock: Mocker, 
example_table_metadata_v2
     assert f"refreshed={different_uuid}" in str(exc_info.value)
 
 
+def test_table_refresh_updates_config(rest_mock: Mocker, 
example_table_metadata_v2: dict[str, Any]) -> None:
+    metadata_location = "s3://warehouse/database/table/metadata.json"
+
+    rest_mock.get(
+        f"{TEST_URI}v1/namespaces/namespace/tables/table_name",
+        json={
+            "metadata-location": metadata_location,
+            "metadata": example_table_metadata_v2,
+            "config": {"original-key": "original-value"},
+        },
+        status_code=200,
+        request_headers=TEST_HEADERS,
+    )
+
+    catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
+    table = catalog.load_table(("namespace", "table_name"))
+    assert table.config == {"original-key": "original-value"}
+
+    rest_mock.get(
+        f"{TEST_URI}v1/namespaces/namespace/tables/table_name",
+        json={
+            "metadata-location": metadata_location,
+            "metadata": example_table_metadata_v2,
+            "config": {"updated-key": "updated-value"},
+        },
+        status_code=200,
+        request_headers=TEST_HEADERS,
+    )
+
+    table.refresh()
+    assert table.config == {"updated-key": "updated-value"}
+
+
 def test_table_uuid_check_on_refresh(rest_mock: Mocker, 
example_table_metadata_v2: dict[str, Any]) -> None:
     original_uuid = "9c12d441-03fe-4693-9a96-a0705ddf69c1"
     different_uuid = "550e8400-e29b-41d4-a716-446655440000"

Reply via email to