You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Srini Naravatla <na...@gmail.com> on 2012/06/07 06:10:25 UTC
pig conditional operators
how do i go about writing simple " CASE " statement in apache pig.
example
------------
case when a1 = b1 then c1
when a = b2 then c2
end
any inputs appreciated.
RE: pig conditional operators
Posted by Ruslan Al-fakikh <ru...@jalent.ru>.
Hi
Use the ternary statement like this:
(a1 == b1) ? c1 : c2
Regards,
Ruslan Al-Fakikh
-----Original Message-----
From: Srini Naravatla [mailto:naravatla@gmail.com]
Sent: Thursday, June 07, 2012 8:10 AM
To: pig-user@hadoop.apache.org
Subject: pig conditional operators
how do i go about writing simple " CASE " statement in apache pig.
example
------------
case when a1 = b1 then c1
when a = b2 then c2
end
any inputs appreciated.
RE: pig conditional operators
Posted by Sal Uryasev <su...@linkedin.com>.
For many usecases, you can do something like this:
result = FOREACH entry GENERATE (a == b ? c1 : c2);
More complicated cases may need to use pig embedding:
http://ofps.oreilly.com/titles/9781449302641/embedding.html
Sal Uryasev
suryasev@linkedin.com
________________________________________
From: Srini Naravatla [naravatla@gmail.com]
Sent: Wednesday, June 06, 2012 9:10 PM
To: pig-user@hadoop.apache.org
Subject: pig conditional operators
how do i go about writing simple " CASE " statement in apache pig.
example
------------
case when a1 = b1 then c1
when a = b2 then c2
end
any inputs appreciated.