hadoop - how to cross join unnest a json array in presto -
given table contains column of json this:
{"payload":[{"type":"b","value":"9"}, {"type":"a","value":"8"}]} {"payload":[{"type":"c","value":"7"}, {"type":"b","value":"3"}]}
how can write presto query give me average b
value across entries?
so far think need use hive's lateral view explode, equivalent cross join unnest in presto.
but i'm stuck on how write presto query cross join unnest
.
how can use cross join unnest
expand array elements , select them?
as pointed out, implemented in presto 0.79. :)
here example of syntax cast here:
select cast(cast ('[1,2,3]' json) array<bigint>);
special word of advice, there no 'string' type in presto there in hive. means if array contains strings make sure use type 'varchar' otherwise error msg saying 'type array not exist' can misleading.
select cast(cast ('["1","2","3"]' json) array<varchar>);
Comments
Post a Comment