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

jerryshao pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 03bca33df9 [Cherry-pick to branch-1.3] [#12324] fix(client-python): 
serialize property field in RemoveCatalogPropertyRequest (#12325) (#12433)
03bca33df9 is described below

commit 03bca33df93989f8d10e538fd555bcd5faabf357
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 12 19:01:23 2026 +0800

    [Cherry-pick to branch-1.3] [#12324] fix(client-python): serialize property 
field in RemoveCatalogPropertyRequest (#12325) (#12433)
    
    **Cherry-pick Information:**
    - Original commit: 38de02edafd0c0ab0aa777ba00dedad973115091
    - Target branch: `branch-1.3`
    - Status: ✅ Clean cherry-pick (no conflicts)
    
    Co-authored-by: Phước <[email protected]>
    Co-authored-by: phuocho <[email protected]>
---
 .../dto/requests/catalog_update_request.py         |   5 +-
 .../tests/integration/test_catalog.py              |  20 ++++
 .../dto/requests/test_catalog_update_request.py    | 108 +++++++++++++++++++++
 3 files changed, 132 insertions(+), 1 deletion(-)

diff --git 
a/clients/client-python/gravitino/dto/requests/catalog_update_request.py 
b/clients/client-python/gravitino/dto/requests/catalog_update_request.py
index 1ea4d9953c..b4ba71c546 100644
--- a/clients/client-python/gravitino/dto/requests/catalog_update_request.py
+++ b/clients/client-python/gravitino/dto/requests/catalog_update_request.py
@@ -105,10 +105,13 @@ class CatalogUpdateRequest:
             if not self._value:
                 raise ValueError('"value" field is required and cannot be 
empty')
 
+    @dataclass
     class RemoveCatalogPropertyRequest(CatalogUpdateRequestBase):
         """Request to remove a property from a catalog."""
 
-        property: Optional[str] = None
+        _property: Optional[str] = field(
+            default=None, metadata=config(field_name="property")
+        )
         """The property to remove."""
 
         def __init__(self, catalog_property: str):
diff --git a/clients/client-python/tests/integration/test_catalog.py 
b/clients/client-python/tests/integration/test_catalog.py
index bd7933e00a..a052b5487f 100644
--- a/clients/client-python/tests/integration/test_catalog.py
+++ b/clients/client-python/tests/integration/test_catalog.py
@@ -158,6 +158,26 @@ class TestCatalog(IntegrationTestEnv):
         )
         self.catalog_name = self.catalog_name + "_new"
 
+    def test_alter_catalog_remove_property(self):
+        self.create_catalog(self.catalog_name)
+
+        property_key = "catalog_remove_property_key"
+        property_value = "catalog_remove_property_value"
+
+        # Set a custom property first so that there is something to remove.
+        catalog = self.gravitino_client.alter_catalog(
+            self.catalog_name,
+            CatalogChange.set_property(property_key, property_value),
+        )
+        self.assertEqual(property_value, 
catalog.properties().get(property_key))
+
+        # Remove the property and assert it is gone from the catalog.
+        catalog = self.gravitino_client.alter_catalog(
+            self.catalog_name,
+            CatalogChange.remove_property(property_key),
+        )
+        self.assertNotIn(property_key, catalog.properties())
+
     def test_drop_catalog(self):
         self.create_catalog(self.catalog_name)
         self.gravitino_client.disable_catalog(self.catalog_name)
diff --git 
a/clients/client-python/tests/unittests/dto/requests/test_catalog_update_request.py
 
b/clients/client-python/tests/unittests/dto/requests/test_catalog_update_request.py
new file mode 100644
index 0000000000..afe16e5cc1
--- /dev/null
+++ 
b/clients/client-python/tests/unittests/dto/requests/test_catalog_update_request.py
@@ -0,0 +1,108 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import json as _json
+import unittest
+
+from gravitino.api.catalog_change import CatalogChange
+from gravitino.dto.requests.catalog_update_request import CatalogUpdateRequest
+
+
+class TestCatalogUpdateRequest(unittest.TestCase):
+    def test_rename_catalog_request_validate(self) -> None:
+        invalid_request = CatalogUpdateRequest.RenameCatalogRequest("")
+
+        with self.assertRaises(ValueError):
+            invalid_request.validate()
+
+    def test_rename_catalog_request_serialize(self) -> None:
+        request = CatalogUpdateRequest.RenameCatalogRequest("newCatalog")
+        json_str = _json.dumps(
+            {
+                "@type": "rename",
+                "newName": "newCatalog",
+            },
+            ensure_ascii=False,
+        )
+
+        self.assertEqual(json_str, request.to_json())
+
+    def test_update_catalog_comment_request_serialize(self) -> None:
+        request = CatalogUpdateRequest.UpdateCatalogCommentRequest("new 
comment")
+        json_str = _json.dumps(
+            {
+                "@type": "updateComment",
+                "newComment": "new comment",
+            },
+            ensure_ascii=False,
+        )
+
+        self.assertEqual(json_str, request.to_json())
+
+    def test_set_catalog_property_request_validate(self) -> None:
+        invalid_request1 = CatalogUpdateRequest.SetCatalogPropertyRequest("", 
"value")
+        invalid_request2 = 
CatalogUpdateRequest.SetCatalogPropertyRequest("key", "")
+
+        with self.assertRaises(ValueError):
+            invalid_request1.validate()
+
+        with self.assertRaises(ValueError):
+            invalid_request2.validate()
+
+    def test_set_catalog_property_request_serialize(self) -> None:
+        request = CatalogUpdateRequest.SetCatalogPropertyRequest("key", 
"value1")
+        json_str = _json.dumps(
+            {
+                "@type": "setProperty",
+                "property": "key",
+                "value": "value1",
+            },
+            ensure_ascii=False,
+        )
+
+        self.assertEqual(json_str, request.to_json())
+
+    def test_remove_catalog_property_request_validate(self) -> None:
+        invalid_request = CatalogUpdateRequest.RemoveCatalogPropertyRequest("")
+
+        with self.assertRaises(ValueError):
+            invalid_request.validate()
+
+        # A non-empty property must pass validation.
+        valid_request = 
CatalogUpdateRequest.RemoveCatalogPropertyRequest("key")
+        valid_request.validate()
+
+    def test_remove_catalog_property_request_serialize(self) -> None:
+        request = CatalogUpdateRequest.RemoveCatalogPropertyRequest("prop1")
+        json_str = _json.dumps(
+            {
+                "@type": "removeProperty",
+                "property": "prop1",
+            },
+            ensure_ascii=False,
+        )
+
+        self.assertEqual(json_str, request.to_json())
+
+    def test_remove_catalog_property_request_catalog_change(self) -> None:
+        request = CatalogUpdateRequest.RemoveCatalogPropertyRequest("prop1")
+
+        self.assertIsInstance(request.catalog_change(), 
CatalogChange.RemoveProperty)
+
+
+if __name__ == "__main__":
+    unittest.main()

Reply via email to