将apache pig转换为hive

问题描述 投票:0回答:1

试图找出“群体”变平,以及这个特殊的“扁平化”代码正在做什么。我一直在研究下面的代码,试图弄清楚如何将它转换为hive几天以上,我只是不明白。通常,他们使用flatten为两个或更多列创建多行,他们希望在输出中命名相同。但在这种情况下,我不确定它是如何在蜂巢中复制它的。任何帮助都会非常感激,因为我没有太多时间来处理这个问题,而我预计会在接下来的几周内完成并测试它。谢谢。

Change_pop = GROUP IPChange_pop BY (acct_num,strategy_code);
Oldest_GLChange = FOREACH Change_pop {
OList = ORDER IPChange_pop BY process_date ASC, new_loc DESC;
Oldest = LIMIT OList 1;
GENERATE
FLATTEN(GLChange_pop) as (email,acct_num,acct_nm,cust_num,type,strategy_code,process_date,last_5,cmGroup,current_loc,new_loc,update_ts),
FLATTEN(group.strategy_code) as grp_strategy_code,
FLATTEN(Oldest.process_date) as early_process_date, FLATTEN(Oldest.new_loc) as early_new_loc;
};
hive apache-pig
1个回答
0
投票

Flatten用于取消嵌套元组,包和地图。从我的头脑中,我记得Hive等效将使用EXPLODE()函数和LATERAL VIEW。

https://pig.apache.org/docs/latest/basic.html#flatten

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-explode

© www.soinside.com 2019 - 2024. All rights reserved.