Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> implementing "if" logic


Copy link to this message
-
Re: implementing "if" logic
Here's a trick I used:

Together with $x, pass in another parameter $comment that's either ''
(blank) when x>0 or '--' (double dashes) when x==0. Then

result = SOME OPERATION
$comment result = LIMIT result $x

On Sun, Mar 27, 2011 at 12:36 PM, souri datta <[EMAIL PROTECTED]>wrote:

> Hi all,
>
> I have a problem where I need to limit the number of results generated by
> pig script based on some condition.
>
> say,
>  if ( $x == 0 )
>  then do not limit #results
>  else:
>   limited_result = LIMIT results $x ;
>
> (here x comes from cmd line)
>
> How can I achieve this with a single Pig script ?
>
> Thanks in advance,
> Souri
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB