MAX is a clever trick, cool, thanks! And, yeah, I can't bear to think about the generalized case of N keys... yet... Mat
On 11 July 2011 06:06, [email protected] <[email protected]>wrote: > You've pretty much got it actually. Don't bother trying to use an empty > bag. The only thing I've ever gotten to work in such situations is the MAX > udf as opposed to FLATTEN. That's assuming you've only got one value per > (uid,key) tuple of course. Here's how to modify your last line: > > flattened = FOREACH cogrouped { > age = (IsEmpty(by_age) ? 'null' : > MAX(by_age.value)); > colour= (IsEmpty(by_colour) ? 'null' : > MAX(by_colour.value)); > food = (IsEmpty(by_food) ? 'null' : > MAX(by_food.value)); > GENERATE group, age, colour, food; > > Hurray. > > What happens with 10 keys? 100? There must be a better way. Anyone else > want to chime in? > > --jacob > @thedatachef > > Sent from my HTC Inspire⢠4G on AT&T > >
