我必须找出在城市上花费的最大金额以及产品。
我的实施:
listItems.clear();
listItems.addAll(newlist);
我得到了什么
A = LOAD '/home/cloudera/Desktop/test' USING PigStorage (',') AS (T_id:int,date:chararray,pro_id:int,amount:int,product:chararray,city:chararray);
B = FOREACH A GENERATE $3,$4,$5;
describe B;
B: {amount: int,product: chararray,city: chararray}
C = group B BY $2;
D = FOREACH C GENERATE group, MAX(B.amount);
DUMP D;
预期输出
(Reno,279)
(clark,2000)
(colum,500)
(Petersburg,421)
(charleston,1974)
(long beach,300)
请帮助我......
答案 0 :(得分:0)
按产品和城市分组。
C = group B BY ($1,$2);
D = FOREACH C GENERATE FLATTEN(group) as (product,city), MAX(B.amount);
DUMP D;