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


##########
clients/client-python/tests/unittests/dto/util/test_dto_converters.py:
##########
@@ -768,3 +778,211 @@ def test_to_dto_list_partition(self):
         )
         converted = DTOConverters.to_dto(partition)
         self.assertTrue(converted == expected)
+
+    def test_to_dtos_columns(self):
+        column_names = {f"column_{i}" for i in range(2)}
+        column_data_types = {Types.IntegerType.get(), Types.BooleanType.get()}
+        columns: list[Column] = [
+            Column.of(name=column_name, data_type=column_data_type)
+            for column_name, column_data_type in zip(column_names, 
column_data_types)
+        ]
+        expected = [
+            ColumnDTO.builder()
+            .with_name(column.name())
+            .with_data_type(column.data_type())
+            .with_default_value(Column.DEFAULT_VALUE_NOT_SET)
+            .build()
+            for column in columns
+        ]
+        self.assertListEqual(DTOConverters.to_dtos(columns), expected)
+
+    def test_to_dtos_sort_orders(self):
+        directions = {SortDirection.ASCENDING, SortDirection.DESCENDING}
+        null_orderings = {NullOrdering.NULLS_LAST, NullOrdering.NULLS_FIRST}
+        field_names = [
+            [f"score_{i}"] for i in range(len(directions) * 
len(null_orderings))
+        ]
+        sort_orders: list[SortOrder] = []
+        expected_dtos: list[SortOrderDTO] = []
+        for field_name, (direction, null_ordering) in zip(
+            field_names, product(directions, null_orderings)
+        ):
+            field_ref = FieldReference(field_names=field_name)
+            sort_orders.append(
+                SortOrders.of(
+                    expression=field_ref,
+                    direction=direction,
+                    null_ordering=null_ordering,
+                )
+            )
+            field_ref_dto = (
+                FieldReferenceDTO.builder()
+                .with_field_name(field_name=field_name)
+                .build()
+            )
+            expected_dtos.append(
+                SortOrderDTO(
+                    sort_term=field_ref_dto,
+                    direction=direction,
+                    null_ordering=null_ordering,
+                )
+            )
+        converted_dtos = DTOConverters.to_dtos(sort_orders)
+        for converted, expected in zip(converted_dtos, expected_dtos):
+            self.assertTrue(converted.sort_term() == expected.sort_term())
+            self.assertTrue(converted.direction() == expected.direction())
+            self.assertTrue(converted.null_ordering() == 
expected.null_ordering())
+
+        self.assertListEqual(DTOConverters.to_dtos(converted_dtos), 
converted_dtos)
+
+    def test_to_dtos_indexes(self):
+        field_names = [[f"field_{i}"] for i in range(2)]
+
+        indexes: list[Index] = [
+            Indexes.of(index_type, index_type.value, field_names)
+            for index_type in Index.IndexType
+        ]
+        expected_dtos: list[IndexDTO] = [
+            IndexDTO(
+                index_type=index_type,
+                name=index_type.value,
+                field_names=field_names,
+            )
+            for index_type in Index.IndexType
+        ]
+        converted_dtos = DTOConverters.to_dtos(indexes)
+        for converted, expected in zip(converted_dtos, expected_dtos):
+            self.assertTrue(converted.type() == expected.type())
+            self.assertTrue(converted.name() == expected.name())

Review Comment:
   fixed in this commit 
(https://github.com/apache/gravitino/pull/9478/commits/9147bbe23caf9759f9fcbabe347477beb550ec1c)



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