带有整数的猪拉丁语中求和函数的错误1045 [英] Error 1045 on sum function in pig latin with an int
问题描述
以下猪拉丁文字:
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.
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.
此错误使我认为我需要将size转换为int,但是如果我描述我的groupedIp
字段,则会得到以下架构.
This error makes me think I need to cast size as an int, but if i describe my groupedIp
field, I get the following schema.
groupedIp: {group: bytearray,splitDate: {(size: int,ip: chararray,h: bytearray)}}
,它指示size是一个int,并且应该能够被sum函数使用.
groupedIp: {group: bytearray,splitDate: {(size: int,ip: chararray,h: bytearray)}}
which indicates that size is an int, and should be able to be used by the sum function.
我不正确地调用sum函数吗?让我知道您是否还要查看其他内容,例如输入文件.
Am I calling the sum function incorrectly? Let me know if you would like to see any thing else, such as the input file.
推荐答案
SUM 作为输入对 bag 进行操作,但是您将其传递给字段'size
'.
尝试消除嵌套的foreach并使用:
SUM operates on a bag as input, but you pass it the field 'size
'.
Try to eliminate the nested foreach and use:
a = foreach groupedIp generate SUM(splitDate.size);
这篇关于带有整数的猪拉丁语中求和函数的错误1045的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!