Quantcast
Viewing all articles
Browse latest Browse all 5648

Extending Pig SUM function

Hi All,
The built in Pig SUM eval function returns null if the bag is empty . How can I override this(as simple as possible ) to return 0 instead of null .
public class CustomSum extends SUM{
// Which methods to override.

Or Is there any way I can do it in script to check if SUM returned null then make it 0.

Eg : A = FOREACH (COGROUP OUTER) group as url , (1-$d)+$d*SUM(a.values) as totalValue .

I am doing a outer COGROUP . So there are some records in the group which doesn't have values and in that case I would like to return constant(1-$d) . However as SUM returns null , totalValues is becoming null.

Thanks,
Abhilash

Viewing all articles
Browse latest Browse all 5648

Trending Articles