零和产生问题

new9mtju  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(175)

我想在hbase的一列中存储0。所以,我在Pig的剧本里做了以下几点。

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  0 AS size:int , ip as ip,  FLATTEN(STRSPLIT(date, ':')) as h;

groupedIp = group splitDate by h.$1;

然后我就这样做了

a = foreach groupedIp generate SUM(splitDate.size);

在控制台上抛出错误

Could not infer the matching function for org.apache.pig.builtin.SUM as multiple or none of them fit. Please use an explicit cast

在这种情况下,有没有什么方法可以不用求和就写零,或者求和处理所有零的方法会很有用。
谢谢。

xwmevbvl

xwmevbvl1#

试试这个-

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  0 AS size:int , ip as ip,  FLATTEN(STRSPLIT(date, ':')) as (h1:chararray,h2:chararray,h3:chararray);

groupedIp = group splitDate by h1;

a = foreach groupedIp generate SUM(splitDate.size);

相关问题