以下猪拉丁文脚本:
data = load 'access_log_Jul95' using PigStorage(' ') as (ip:chararray, dash1:chararray, dash2:chararray, date:chararray, date1:chararray, getRequset:chararray, location:chararray, http:chararray, code:int, size:int);
splitDate = foreach data generate size as size:int , ip as ip, FLATTEN(STRSPLIT(date, ':')) as h;
groupedIp = group splitDate by h.$1;
a = foreach groupedIp{
added = foreach splitDate generate SUM(size); --
generate added;
};
describe a;
给我错误:
ERROR 1045:
<file 3.pig, line 10, column 39> Could not infer the matching function for org.apache.pig.builtin.SUM as multiple or none of them fit. Please use an explicit cast.
这个错误让我觉得我需要将大小转换为 int,但如果我描述我的groupedIp
领域,我会得到以下架构。
groupedIp: {group: bytearray,splitDate: {(size: int,ip: chararray,h: bytearray)}}
这表明 size 是一个 int,并且应该能够被 sum 函数使用。
我是否错误地调用了 sum 函数?让我知道您是否想查看其他内容,例如输入文件。