JingsongLi commented on code in PR #4848:
URL: https://github.com/apache/paimon/pull/4848#discussion_r1904815874


##########
paimon-common/src/test/java/org/apache/paimon/casting/CastExecutorTest.java:
##########
@@ -681,6 +690,65 @@ public void testTimeToTimestamp() {
                 DateTimeUtils.parseTimestampData("1970-01-01 " + time, 3));
     }
 
+    @Test
+    public void testArrayToString() {
+        ArrayType arrayType = new ArrayType(DataTypes.INT());
+        GenericArray genericArray = new GenericArray(new Integer[] {1, null, 
2});
+        compareCastResult(
+                CastExecutors.resolve(arrayType, DataTypes.STRING()),
+                genericArray,
+                BinaryString.fromString("[1, null, 2]"));
+    }
+
+    @Test
+    public void testMapToString() {
+        MapType mapType = new MapType(DataTypes.INT(), DataTypes.STRING());
+        Map<Object, Object> javaMap = new HashMap<>();
+        javaMap.put(1, BinaryString.fromString("i"));
+        javaMap.put(2, BinaryString.fromString("miss"));
+        javaMap.put(3, BinaryString.fromString("you"));
+        javaMap.put(4, null);
+        GenericMap genericMap = new GenericMap(javaMap);
+        compareCastResult(
+                CastExecutors.resolve(mapType, DataTypes.STRING()),
+                genericMap,
+                BinaryString.fromString("{1 -> i, 2 -> miss, 3 -> you, 4 -> 
null}"));
+    }
+
+    @Test
+    public void testRowToString() {
+        RowType rowType =
+                DataTypes.ROW(
+                        DataTypes.FIELD(0, "f0", DataTypes.INT()),
+                        DataTypes.FIELD(
+                                1,
+                                "f1",
+                                DataTypes.ROW(
+                                        DataTypes.FIELD(2, "f0", 
DataTypes.DATE()),
+                                        DataTypes.FIELD(
+                                                3,
+                                                "f1",
+                                                new MapType(
+                                                        DataTypes.INT(),
+                                                        new 
ArrayType(DataTypes.INT()))),
+                                        DataTypes.FIELD(4, "f2", 
DataTypes.INT()))));
+
+        HashMap<Integer, GenericArray> javaMap = new HashMap<>();
+        javaMap.put(1, new GenericArray(new Integer[] {1, null, 2}));
+        GenericRow row =
+                GenericRow.of(
+                        1,
+                        GenericRow.of(
+                                DateTimeUtils.parseDate("2025-01-06"),
+                                new GenericMap(javaMap),
+                                null));
+
+        compareCastResult(
+                CastExecutors.resolve(rowType, DataTypes.STRING()),
+                row,
+                BinaryString.fromString("{1, {2025-01-06, {1 -> [1, null, 2]}, 
null}}"));

Review Comment:
   Ditto, (why not using `(abc, def)`)



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