Does pig script support if-else statement
here is what I want to do:
if($NAME=='Joey') Do something else Do something
is that doable?
Thanks
Its Called a "Bincond" Operator
Statements Like:
(Price > 75 ? 'High':'Low')
are also valid
For Handling Null Records:
((Name is null or IsEmpty(Name)) ? {('unknown')} : Name)
Use them in a foreach statement with alias along other fields i.e:
A = load 'x/y/Price.csv' as (Name, Product, Price);
B = foreach A generate Name, Product, Price, (Price > 75 ? 'High':'Low') as Indicator;
dump B;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With