"value1","key2"=>"value2"? Simple CAST AS does not work. json_format also do" /> "value1","key2"=>"value2"? Simple CAST AS does not work. json_format also do" /> "value1","key2"=>"value2"? Simple CAST AS does not work. json_format also do"/>

How cast Map(varchar,varchar) to string in trino?

32 Views Asked by At

I have column with Map(varchar,varch) how to cast to string? Like "key1"=>"value1","key2"=>"value2"? Simple CAST AS does not work. json_format also does not work.

1

There are 1 best solutions below

0
Guru Stron On

You can cast it to JSON and then format it (formatting can be skipped in some cases):

select JSON_FORMAT(cast(map(array['a', 'b'], array['42', '777']) as JSON));

Output:

        _col0
----------------------
 {"a":"42","b":"777"}