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'
我有沒有這個工作的版本?