我正在尝试重命名包含3个元组($2,$7)
,($8,$9)
和($3,$6)
的Pig包。
示例:
collected = FOREACH collect GENERATE $0 as guest_id
, TOTUPLE($4, $5) AS guest_group
, TOBAG(TOTUPLE($2, $7) AS demographic_type
, TOTUPLE($8, $9) AS demographic_level
, TOTUPLE($3, $6) AS demographic
, $1 AS quater_end_date) AS guest_demographic;
但它不起作用。但是,如果我执行以下命令重命名元组,它可以正常工作。
collected = FOREACH collect GENERATE $0 as guest_id
, TOTUPLE($4, $5) AS guest_group
, TOTUPLE($2, $7) AS demographic_type
, TOTUPLE($8, $9) AS demographic_level
, TOTUPLE($3, $6) AS demographic
, $1 as quater_end_date;
DESCRIBE collected;
收集:{guest_id:int,guest_group:(gst_ten_pcnt_flag:chararray,gst_two_pcnt_flag:chararray),demographic_type:(typ_code:int,typ_name:chararray),demographic_level:(dmg_typ_lvl:chararray,dmg_typ_lvl_name:chararray),人口统计:(dmg_val :chararray,val_name:chararray),quater_end_date:chararray}
有人可以建议如何在Pig中重命名一个包,这样当我描述它时我会得到
收集:{guest_id:int,guest_group:(gst_ten_pcnt_flag:chararray,gst_two_pcnt_flag:chararray),人口统计:{demographic_type:(typ_code:int,typ_name:chararray),demographic_level:(dmg_typ_lvl:chararray,dmg_typ_lvl_name:chararray),人口统计:(dmg_val:chararray,val_name:chararray),quater_end_date:chararray}}
答案 0 :(得分:0)
参考:http://pig.apache.org/docs/r0.12.0/func.html#tobag
用法:TOBAG(field1,field2,...)
collected = FOREACH collect Generate $0 as guest_id, TOTUPLE($4, $5) as guest_group, TOBAG($2, $7) as demographic_type, TOTUPLE($8, $9) as demographic_level, TOTUPLE($3, $6) as demographic, $1 as quater_end_date ...;