横向视图快速爆炸

LATERAL VIEW EXPLODE in presto

presto 的新手,任何指针如何在 table.

以下的 presto 中使用 LATERAL VIEW EXPLODE

我需要在我的 presto 查询中过滤名称

CREATE EXTERNAL TABLE `id`(
 `id` string,
 `names` map<string,map<string,string>>,
 `tags` map<string,map<string,string>>)
ROW FORMAT SERDE
 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' 
STORED AS INPUTFORMAT
 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' 
OUTPUTFORMAT
 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
 's3://test'

;

样本names值:

{3081={short=Abbazia 81427 - Milan}, 2057={short=Abbazia 81427 - Milan}, 1033={short=Abbazia 81427 - Milan}, 4105={short=Abbazia 81427 - Milan}, 5129={short=Abbazia 81427 - Milan}}

来自文档:https://trino.io/docs/current/appendix/from-hive.html

Trino [formerly PrestoSQL] supports UNNEST for expanding arrays and maps. Use UNNEST instead of LATERAL VIEW explode().

Hive 查询:

SELECT student, score
FROM tests
LATERAL VIEW explode(scores) t AS score;

Presto 查询:

SELECT student, score
FROM tests
CROSS JOIN UNNEST(scores) AS t (score);

我能够运行下面的查询来获取映射数据

select
id
,names['1033']['short'] as srt_nm
from id;