我有以下输入数据表:
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
也许有人可以帮忙,如何获得这个输出?