Writing UDF in Python for Pig

I’ve struggled on this problem for several hours. Hope anyone can help me. The input is bag structure, such as {([1,2]),([3,4])}, and the goal is to output the sum of corresponding element of tuples in the bag, say (4,6). Thanks a lot.

My code:
@outputSchema(‘aa:chararray’)
def func(input):
aa = map(sum,zip(*,input))
aa = str(aa)
return aa

TypeError: unsupported operand type(s) for +: ‘int’ and ‘unicode’


Source: python

Leave a Reply