我有以下输入数据表:
Product Price Country
A 5 Italy
B 4 USA
C 12 France
A 5 Italy
B 7 Russia
我正在通过2个ID(产品和国家/地区)进行总结操作。代码如下:
t3 = LOAD '/home/Desktop/3_table.data' USING PigStorage('\t') AS (product:chararray, price:int, country:chararray);
group_pr = GROUP t3 BY (product, country);
price_1 = FOREACH group_pr GENERATE CONCAT(group.product, group.country), SUM(t3.price);
STORE price_1 INTO 'sum_by_product_country' USING PigStorage('\t');
输出结果为:
AItaly 10
BUSA 4
BRussia 7
CFrance 12
问题是,我必须得到包含输入数据的完整表并一起输出,所以期望输出应该是这样的:
A 5 Italy AItaly 10
B 4 USA BUSA 4
C 12 France CFrance 12
B 7 Russia BRussia 7
也许有人可以提供帮助,如何获得此输出?