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

Switch to Plain View
Pig, mail # user - Issues with Bincond


+
Alex Rovner 2012-08-22, 18:28
Copy link to this message
-
Re: Issues with Bincond
Cheolsoo Park 2012-08-22, 18:37
Hi Alex,

I think that that's expected. The Pig manual says the following
regarding comparison
operators (e.g. ==):

If either sub-expression is null, the result is null.
So "col1 == null" is null.

Now it also says the following regarding arithmetic operators (e.g. ?):

If either sub-expression is null, the resulting expression is null.
So "col1 == null ? 'null' : 'not-null'" is null as "col1 == null" is null.

Here is the link:
http://pig.apache.org/docs/r0.10.0/basic.html#nulls

Thanks,
Cheolsoo

On Wed, Aug 22, 2012 at 11:28 AM, Alex Rovner <[EMAIL PROTECTED]> wrote:

> I am having trouble with bincond in pig 11.
>
> Sample input:
> 1234
> 0
> 1234
>
> Sample pig script:
> a = LOAD 'input.txt' as (col1:int);
>
> b = FOREACH a GENERATE col1, (col1 == null ? 'null' : 'not-null') as col2;
>
> dump b;
>
>
> Output:
> (1234,)
> (0,)
> (1234,)
>
>
> Certainly not what you expect to see... I expected to see 'not-null' string
> in the second column.
> If I change the bincond to look for a particular value then everything
> works as expected:
>
> b = FOREACH a GENERATE col1, (col1 == 1234 ? 'null' : 'not-null') as col2;
>
> Output:
> (1234,null)
> (0,not-null)
> (1234,null)
>
>
> Any ideas? I did not get a chance to test this with prior versions.
>
> Thanks
> Alex
>
+
Alex Rovner 2012-08-22, 18:43
+
Alan Gates 2012-08-22, 20:42
+
Alex Rovner 2012-08-22, 21:34