Pig if-else condition
<p>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 <strong>syn</strong> is not blank, in which case (if TRUE) the value would be 1, else it would be 0.</p>
<p>Here's the code</p>
<pre><code>B = foreach A generate t, (syn!='' ? 1 : 0) as s;
</code></pre>
<p>The command runs without a glitch but when i dump the results, this happens:</p>
<pre><code>(8758.414086,)
(8758.457255,1)
</code></pre>
<p>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.</p>
<p><strong>EDIT:</strong> for anyone interested I found a solution, although the original question remains. Instead of the <code>==</code> operator, I used</p>
<p><code>B = foreach A generate t, (syn is not null ? 1 : 0) as s;</code></p>
<p>and it worked like a charm. However my question remains.</p>