Thejas Nair
Wed, 10 Mar 2010 05:46:19 -0800
On 3/9/10 10:42 PM, "Mridul Muralidharan" <mrid...@yahoo-inc.com> wrote:
> On Saturday 06 March 2010 04:35 AM, hc busy wrote:
>> Guys, I have some data that has null bag. Looking at the COUNT.java it seems
>> that it is an error condition for the bag passed in to be null (instead of
>> zero for example.)
>>
>> I tried to change it to an empty bag when it's null
>>
>> data = FOREACH input GENERATE bagField is null?{}:bagField as bagField;
>> count = FOREACH data GENERATE count(bagField);
>
>
> Cant you not combine both of these lines into a single one ? Does that
> work ?
> Something like :
>
> count = FOREACH input GENERATE COUNT((bagField is not null? bagField : {}));
>
>
It can be combined, but in this case you would still get the same error:
"Two inputs of BinCond must have compatible schemas."
As hc busy suggested this is a better solution - ( count on bag will not be
a called if b is null) -
foreach f generate b is null ? 0 : COUNT(b);