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


##########
clients/client-python/gravitino/dto/util/dto_converters.py:
##########
@@ -76,3 +94,219 @@ def from_function_args(args: list[FunctionArg]) -> 
list[Expression]:
         if not args:
             return Expression.EMPTY_EXPRESSION
         return [DTOConverters.from_function_arg(arg) for arg in args]
+
+    @singledispatchmethod
+    @staticmethod
+    def from_dto(dto) -> object:
+        raise IllegalArgumentException(f"Unsupported DTO type: {type(dto)}")
+
+    @from_dto.register
+    @staticmethod
+    def _(dto: DistributionDTO) -> Distribution:
+        """Converts a DistributionDTO to a Distribution.
+
+        Args:
+            dto (DistributionDTO): The distribution DTO.
+
+        Returns:
+            Distribution: The distribution.
+        """
+        if dto is None or DistributionDTO.NONE.equals(dto):
+            return Distributions.NONE
+
+        return Distributions.of(
+            dto.strategy(),
+            dto.number(),
+            *DTOConverters.from_function_args(dto.args()),
+        )
+
+    @from_dto.register
+    @staticmethod
+    def _(dto: IndexDTO) -> Index:
+        """Converts an IndexDTO to an Index.
+
+        Args:
+            dto (IndexDTO): The Index DTO to be converted.
+
+        Returns:
+            Index: The index.
+        """
+        return Indexes.of(dto.type(), dto.name(), dto.field_names())
+
+    @from_dto.register
+    @staticmethod
+    def _(dto: SortOrderDTO) -> SortOrder:
+        """Converts a SortOrderDTO to a SortOrder.
+
+        Args:
+            dto (SortOrderDTO): The sort order DTO to be converted.
+
+        Returns:
+            SortOrder: The sort order.
+        """
+        return SortOrders.of(
+            DTOConverters.from_function_arg(dto.sort_term()),
+            dto.direction(),
+            dto.null_ordering(),
+        )
+
+    @from_dto.register
+    @staticmethod
+    def _(dto: ColumnDTO) -> Column:
+        """Converts a ColumnDTO to a Column.
+
+        Args:
+            dto (ColumnDTO): The column DTO to be converted.
+
+        Returns:
+            Column: The column.
+        """
+        dto_default_value = dto.default_value()
+        return Column.of(
+            dto.name(),
+            dto.data_type(),
+            dto.comment(),
+            dto.nullable(),
+            dto.auto_increment(),
+            (
+                None
+                if dto_default_value == Column.DEFAULT_VALUE_NOT_SET
+                else DTOConverters.from_function_arg(dto.default_value())
+            ),
+        )
+
+    @from_dto.register
+    @staticmethod
+    def _(dto: Partitioning) -> Transform:  # pylint: 
disable=too-many-return-statements
+        """Converts a partitioning DTO to a Transform.
+
+        Args:
+            dto (Partitioning): The partitioning DTO to be converted.
+
+        Returns:
+            Transform: The transform.
+        """
+        strategy = dto.strategy()
+        if strategy is Partitioning.Strategy.IDENTITY:
+            return Transforms.identity(dto.field_name())

Review Comment:
   Explicit type casting has been done in this 
[commit](https://github.com/apache/gravitino/pull/8841/commits/58917a4eb28ba3de5d62e59d30ff395d5b6e066c)



-- 
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