tsungchih commented on code in PR #10575:
URL: https://github.com/apache/gravitino/pull/10575#discussion_r3015775855


##########
clients/client-python/tests/unittests/dto/util/test_dto_converters_to_table_update_request.py:
##########
@@ -0,0 +1,287 @@
+# 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 unittest
+from typing import cast
+
+from gravitino.api.rel.column import Column
+from gravitino.api.rel.expressions.literals.literals import Literals
+from gravitino.api.rel.indexes.index import Index
+from gravitino.api.rel.table_change import TableChange
+from gravitino.api.rel.types.types import Types
+from gravitino.dto.rel.expressions.literal_dto import LiteralDTO
+from gravitino.dto.requests.table_update_request import TableUpdateRequest
+from gravitino.dto.util.dto_converters import DTOConverters
+from gravitino.exceptions.base import IllegalArgumentException
+
+
+class TestDTOConvertersToTableUpdateRequest(unittest.TestCase):
+    def test_to_table_update_request_add_column_with_default_value(self):
+        """Tests the conversion of an add column change with a default value 
to a TableUpdateRequest."""
+        add_column = TableChange.add_column(
+            field_name=["new_col"],
+            data_type=Types.IntegerType.get(),
+            comment="test column",
+            nullable=False,
+            auto_increment=True,
+            default_value=Literals.integer_literal(10),
+        )
+        result = cast(
+            TableUpdateRequest.AddTableColumnRequest,
+            DTOConverters.to_table_update_request(add_column),
+        )
+        self.assertIsInstance(result, TableUpdateRequest.AddTableColumnRequest)
+        add_column_request = cast(TableUpdateRequest.AddTableColumnRequest, 
result)
+        self.assertListEqual(add_column_request.field_name, ["new_col"])
+        self.assertEqual(add_column_request.data_type, Types.IntegerType.get())
+        self.assertEqual(add_column_request.comment, "test column")
+        self.assertIsNone(add_column_request.position)
+        self.assertFalse(add_column_request.is_nullable)
+        self.assertTrue(add_column_request.is_auto_increment)
+
+    def test_to_table_update_request_add_column_without_default_value(self):
+        """Tests the conversion of an add column change without a default 
value to a TableUpdateRequest."""
+        add_column = TableChange.add_column(
+            field_name=["new_col"],
+            data_type=Types.StringType.get(),
+        )
+        result = DTOConverters.to_table_update_request(add_column)
+        self.assertIsInstance(result, TableUpdateRequest.AddTableColumnRequest)
+        add_column_request = cast(TableUpdateRequest.AddTableColumnRequest, 
result)
+        self.assertEqual(
+            add_column_request.default_value,
+            Column.DEFAULT_VALUE_NOT_SET,
+        )

Review Comment:
   addressed



##########
clients/client-python/tests/unittests/test_relational_catalog.py:
##########
@@ -276,3 +296,150 @@ def test_list_tables_invalid_namespace(self):
         ):
             with self.assertRaises(NoSuchSchemaException):
                 
self.catalog.list_tables(namespace=Namespace.of("invalid_schema"))
+
+    def test_drop_table(self):
+        resp_body = DropResponse(0, True)
+        mock_resp = self._get_mock_http_resp(resp_body.to_json())
+
+        with patch(
+            "gravitino.utils.http_client.HTTPClient.delete",
+            return_value=mock_resp,
+        ):
+            is_dropped = self.catalog.drop_table(self.table_identifier)
+            self.assertTrue(is_dropped)
+
+    def test_purge_table(self):
+        resp_body = DropResponse(0, True)
+        mock_resp = self._get_mock_http_resp(resp_body.to_json())
+
+        with patch(
+            "gravitino.utils.http_client.HTTPClient.delete",
+            return_value=mock_resp,
+        ):
+            is_dropped = self.catalog.purge_table(self.table_identifier)
+            self.assertTrue(is_dropped)

Review Comment:
   addressed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to