Here's my PIG script:
json = LOAD '/tmp/events/*/*/flume-.*' USING JsonLoader('state:chararray, city:chararray, promotionType:chararray, promotionPlace: chararray, purchase:int');
grouped = FOREACH (group json BY (state, city, promotionType, promotionPlace)) GENERATE group, SUM(json.purchase) as purchase;
grpd = GROUP grouped BY group.city;
top1 = foreach grpd {sorted = order grouped by purchase desc;top = limit sorted 1;generate group, flatten(top);};
DUMP top1;
It works for several files, but for multiple files(3k) it gives error: 'unable to open iterator for alias top1'. Any ideas how to solve this?