0
我想用一堆用户功能(比如国家,语言,注册日期等等),并以非规范化的'long'格式在Hive中生成它们,也就是表格中的行(userid,feature name,feature值),其中特征名称类似于“国家”,特征值类似于“美国”。如何将Hive地图分解为非规范化(“长”)格式?
我正在使用Hive 0.13。
为简单起见,下面的例子都有一个特征(国家),但如果我能找到一个工作,我会添加更多。
查询#1:
select explode(map('country', get_json(json, 'country')))
from users
这工作,其结果的两列(键,值),其中的结果看起来像
country US
country CA
...
查询#2:
select id, explode(map('country', get_json(json, 'country')))
from users
这不合格
FAILED: SemanticException [Error 10081]: UDTF's are not supported
outside the SELECT clause, nor nested in expressions
查询#3:
select key, value
from users
lateral view explode(map('country', get_json(json, 'country')))
此失败
FAILED: ParseException line 3:63 cannot recognize input
near '' '' '' in table alias
查询#4:
select key, value
from users
lateral view explode(map('country', get_json(json, 'country'))) as (key, value)
此失败
FAILED: ParseException line 3:67 missing EOF at '(' near 'as'
我有没有这个工作的版本?