我有以下pig tuple输出:
dump g:
()
(97)
(245)
(870)
(480)
describe g:
g: {long}
我想总结一下以上#的总数,所以我尝试了以下方法:
h = foreach g generate SUM($0);
我收到这个错误:
Please use an explicit cast.
然后我尝试将值强制转换为(int),但仍然不起作用。
我想要的输出是这样的:
1692
以下是代码:
a = LOAD 'tellers' using TextLoader() AS line;
# convert a to charrarry
b = foreach a generate (chararray)line;
# run through my UDF to create tuples
c = foreach b generate myudfs.TellerParser5(line); # ({(20),(5),(5),(10)(1),(1),(1),(1),(1),(5),(10),(10),(10)})....
d = foreach c generate flatten(number);
e = group d by number; #{group: chararray,d: {(number: chararray)}}
f = foreach e generate group, COUNT(d); # f: {group: chararray,long}
g = foreach f generate (long)$0 * $1;
1条答案
按热度按时间xyhw6mcr1#
你需要这样做: