tsungchih commented on code in PR #9870:
URL: https://github.com/apache/gravitino/pull/9870#discussion_r2776940212
##########
clients/client-python/gravitino/dto/requests/table_updates_request.py:
##########
@@ -14,33 +14,35 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
from __future__ import annotations
from dataclasses import dataclass, field
-from typing import Optional
-from dataclasses_json import config, dataclass_json
+from dataclasses_json import config
+from gravitino.dto.requests.table_update_request import TableUpdateRequest
from gravitino.rest.rest_message import RESTRequest
-from gravitino.utils.precondition import Precondition
-@dataclass_json
@dataclass
-class TagCreateRequest(RESTRequest):
- """Represents a request to create a tag."""
+class TableUpdatesRequest(RESTRequest):
+ """Represents a request to update a table."""
- _name: str = field(metadata=config(field_name="name"))
- _comment: Optional[str] = field(default=None,
metadata=config(field_name="comment"))
- _properties: Optional[dict[str, str]] = field(
- default_factory=dict, metadata=config(field_name="properties")
+ _updates: list[TableUpdateRequest] = field(
+ metadata=config(field_name="updates"), default_factory=list
)
+ def __init__(self, updates: list[TableUpdateRequest]) -> None:
+ self._updates = updates
+
def validate(self) -> None:
- """
- Validate the request.
- """
+ """Validates the request.
- Precondition.check_string_not_empty(
- self._name, "name is required and cannot be empty"
- )
+ Raises:
+ ValueError: If the request is invalid.
+ """
+ if not self._updates:
+ raise ValueError("Updates cannot be empty")
+ for update_request in self._updates:
+ update_request.validate()
Review Comment:
We can leverage
[precondition](https://github.com/apache/gravitino/blob/40007c804c21572b9ec015e5e3c1b04665d4dcce/clients/client-python/gravitino/utils/precondition.py)
here.
--
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]