dimanche 31 janvier 2016

Pig if-else condition

I have a file, that I'm loading to pig and doing some nice work on it. Everything goes smoothly until I reach to the point in which I need to use a condition, a kind of if-else statement. I want to check if the variable syn is not blank, in which case (if TRUE) the value would be 1, else it would be 0.

Here's the code

B = foreach A generate t, (syn!='' ? 1 : 0) as s;

The command runs without a glitch but when i dump the results, this happens:

(8758.414086,)
(8758.457255,1)

So when the condition is TRUE the value is added to B. But, I cannot seem to understand why on earth the else part is being left out, instead of adding the 0. Any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire