amazon-web-services - 横向视图快速爆炸
问题描述
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}}
解决方案
来自文档:https ://trino.io/docs/current/appendix/from-hive.html
Trino [原 PrestoSQL] 支持UNNEST扩展数组和映射。使用
UNNEST
而不是LATERAL VIEW explode()
.
蜂巢查询:
SELECT student, score
FROM tests
LATERAL VIEW explode(scores) t AS score;
快速查询:
SELECT student, score
FROM tests
CROSS JOIN UNNEST(scores) AS t (score);
推荐阅读
- java - 在Java中一次读取多行
- php - 以 php 形式附加图像并使用 html2pdf
- spring - Kotlin Spring Boot 多对多关系在 JoinTable 中具有附加值
- excel - 如何查找表中的冲突数?
- python - 将滑块值传递给瓶子路线功能
- python - 看不到我实施 set_data 的错误,所以我不需要再做整个情节
- structure - 尝试使用 WinDbg 查看内存中的 _FILE_ID_BOTH_DIR_INFORMATION 结构
- git - 有没有更简单的方法可以从 monorepo 发布到不同的 repos?
- reactjs - 为什么 lodash get 在反应生产构建中返回未定义的嵌套对象?
- c - 使用 fread 读入 16 字节块