Zouxxyy commented on code in PR #4848:
URL: https://github.com/apache/paimon/pull/4848#discussion_r1904915169
##########
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}"));
Review Comment:
Here are some examples from other engines, I did not find examples of
Snowflake.
Flink
```
select cast (row(1, 'a') as string), cast(map[1, 'a'] as string), cast
(array[1,2,3] as string);
-- | -- | --
(1,a) | {1=a} | [1, 2, 3]
```
Spark
```
spark-sql> select cast (struct(1, 'a') as string), cast (map(1, 'a') as
string), cast (array(1,2,3) as string);
+----------------------------+-------------------------+------------------------------+
|CAST(struct(1, a) AS STRING)|CAST(map(1, a) AS STRING)|CAST(array(1, 2, 3)
AS STRING)|
+----------------------------+-------------------------+------------------------------+
| {1, a}| {1 -> a}|
[1, 2, 3]|
+----------------------------+-------------------------+------------------------------+
```
Trino (can't cast, just show)
```
trino> select row(1, 'a'), map(ARRAY[1], ARRAY['a']), array[1,2,3];
_col0 | _col1 | _col2
--------+-------+-----------
{1, a} | {1=a} | [1, 2, 3]
```
StarRocks (can't cast, just show)
```
select row(1, 'a'), map(1, 'a'), [1, 2, 3];
{"col1":1,"col2":"a"} | {1:"a"} | [1,2,3]
```
--
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]