You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by patcharee <Pa...@uni.no> on 2015/01/20 09:28:44 UTC
IF-ELSE
Hi,
I know that there is no if-else in pig, but is it possible to implement
this logic in some way "if a input parameter is null, skip this filter
operation" ?
IF ($MONTH != NULL)
data_filter_by_month = FILTER data by month == $MONTH;
BR,
Patcharee
Re: IF-ELSE
Posted by Rodrigo Ferreira <we...@gmail.com>.
Depending on the version you are using you can use bincond operators
(<0.12) or CASE WHEN (>=0.12).
http://pig.apache.org/docs/r0.12.0/basic.html#arithmetic
Rodrigo.
2015-01-20 8:18 GMT-02:00 Serega Sheypak <se...@gmail.com>:
> You can apply ternary operator or SPLIT function
>
> 2015-01-20 11:28 GMT+03:00 patcharee <Pa...@uni.no>:
>
> > Hi,
> >
> > I know that there is no if-else in pig, but is it possible to implement
> > this logic in some way "if a input parameter is null, skip this filter
> > operation" ?
> >
> > IF ($MONTH != NULL)
> > data_filter_by_month = FILTER data by month == $MONTH;
> >
> > BR,
> > Patcharee
> >
>
Re: IF-ELSE
Posted by Serega Sheypak <se...@gmail.com>.
You can apply ternary operator or SPLIT function
2015-01-20 11:28 GMT+03:00 patcharee <Pa...@uni.no>:
> Hi,
>
> I know that there is no if-else in pig, but is it possible to implement
> this logic in some way "if a input parameter is null, skip this filter
> operation" ?
>
> IF ($MONTH != NULL)
> data_filter_by_month = FILTER data by month == $MONTH;
>
> BR,
> Patcharee
>