How to cross join unnest a JSON array in Presto

后端 未结 3 1981
孤独总比滥情好
孤独总比滥情好 2021-01-04 13:33

Given a table that contains a column of JSON like this:

{\"payload\":[{\"type\":\"b\",\"value\":\"9\"}, {\"type\":\"a\",\"value\":\"8\"}]}
{\"payload\":[{\"t         


        
3条回答
  •  心在旅途
    2021-01-04 14:21

    As you pointed out, this was finally implemented in Presto 0.79. :)

    Here is an example of the syntax for the cast from here:

    select cast(cast ('[1,2,3]' as json) as array);
    

    Special word of advice, there is no 'string' type in Presto like there is in Hive. That means if your array contains strings make sure you use type 'varchar' otherwise you get an error msg saying 'type array does not exist' which can be misleading.

    select cast(cast ('["1","2","3"]' as json) as array);
    

提交回复
热议问题