Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> BinCond

soniya B 2013-04-27, 14:53
Hello Soniya,

       It's like the ternary or the conditional operator available in java
and works just like that. Here is the example provided in the reference
manual :

*Suppose we have relation A.*

A = LOAD 'data' AS (f1:int, f2:int, B:bag{T:tuple(t1:int,t2:int)});


*In this example the modulo operator is used with fields f1 and f2.*

X = FOREACH A GENERATE f1, f2, f1%f2;


*In this example the bincond operator is used with fields f2 and B. The
condition is "f2 equals 1"; if the condition is true, return 1; if the
condition is false, return the count of the number of tuples in B.*

X = FOREACH A GENERATE f2, (f2==1?1:COUNT(B));

It clearly shows that when "f2==1", which is the first case the exp
evaluates to true, hence "1" is returned and count(B) is returned in rest
of the 2 cases as exp evaluates to false.

What were you trying to do and what exactly is the problem which you are

Warm Regards,
On Sat, Apr 27, 2013 at 8:23 PM, soniya B <[EMAIL PROTECTED]> wrote:

> Hi,
> Anyone can explain me about use of BinCond function with an example?  I am
> trying a lot but didn't work it.
> Regards
> Soniya
soniya B 2013-04-28, 02:12