侧面视图爆炸

时间:2018-07-12 20:48:58

标签: amazon-web-services hive cloud presto

presto的新手,任何指针如何在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}}

2 个答案:

答案 0 :(得分:12)

摘自文档:https://prestodb.io/docs/current/migration/from-hive.html

Presto支持UNNEST扩展数组和地图。使用UNNEST而不是LATERAL VIEW explode()。

配置查询:

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);

答案 1 :(得分:-2)

我能够在查询下面运行以获取映射数据

PublishProcessor