Hi James, I use ternary expressions for this: foreach joined generate ( rel1.x is null ? rel2.x : rel1.x) as x;
On Mon, Aug 29, 2011 at 11:15 AM, James Kebinger <[email protected]>wrote: > My apologies if this is in the docs somewhere, I was unable to find > anything, but I might be calling it the wrong name. > > I'm doing a full outer join in Pig - as such, one or the other join keys > may > be null. I'd like to be able to look at 2 columns, and retrieve just the > one > that is not null. Is that possible? > > I tried an expression in generate with is null and the ternary operator, > and > took a look at DECODE. That might do the trick but wasn't sure if null > checking would work, and if other expressions could appear inside the > decode. > > In my case the fields are integers, so I abused the MAX and TOBAG operators > like this MAX(TOBAG(rx_keyed::u2,cx_keyed::u2)) to get the effect I was > after, but I would love to know if there's a better way. > > Thanks for your time! > > -James Kebinger >
