按照办公文档https://trino.io/docs/current/functions/map.html。我使用“map_entries”将映射分解为数组(行(K,V))结构。我的问题是如何从行对象中提取 K 和 V 值?目前我必须将它重铸为我定义的 Row 对象。
select
type.n , type.b
from
(select
CAST(type AS ROW(n VARCHAR, b VARCHAR)) as type
from
search.yli_tmp_trevi_requests_mini
cross join
unnest (map_entries(cast(json_extract(req, '$.types') as MAP<VARCHAR, VARCHAR>))) t (type)
) t
where
type.n = 'apple'