我有一张蜂巢桌,由Spark / Parquet更新evry小时
CREATE TABLE IF NOT EXISTS user
(
name STRING,
creation_date DATE,
cards map<STRING,STRING>
) STORED AS PARQUET ;
我们假设我想查询每位用户的Gobelin卡数量。
我的查询如下:
select * from user where card["Gobelin"] IS NOT NULL ;
结果如下所示
KillerZord1001 2016-01-02 {"Archer":"2","Gobelin":"6"}
HalfAMill 2016-02-05 {"Witch":"7","Gobelin":"8"}
但我想要的是我正在寻找的钥匙的价值,更像是:
KillerZord1001 2016-01-02 6
HalfAMill 2016-02-05 8
Hive可以执行此类查询吗?
答案 0 :(得分:8)
你可以简单地做
SELECT name, creation_date, card["Gobelin"] FROM USER
WHERE card["Gobelin"] IS NOT NULL