You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Mohit Anchlia <mo...@gmail.com> on 2012/12/26 04:35:29 UTC

Replacing string in input parameter

I am trying to replace string in the input parameter. Is something like
this possible? I am passing comma separated list of dirs and I have several
sub dirs that I need to read from individually in those dirs so that after
loading I can stored them as merged ouput


pig -p
input_path="/user/apuser/web-analytics/flume-output//2012/12/21/13/output,/user/apuser/web-analytics/flume-output//2012/12/21/14/output"
new_m.pig

%declare page_input_path REPLACE($input_path,"output","output/page")

%declare network_input_path REPLACE($input_path,"output","output/network")

Re: Replacing string in input parameter

Posted by Mohit Anchlia <mo...@gmail.com>.
thanks!

On Thu, Dec 27, 2012 at 9:34 AM, Rohini Palaniswamy <rohini.aditya@gmail.com
> wrote:

> Take a look at http://pig.apache.org/docs/r0.10.0/cont.html#Parameter-Sub-
> Specifying Parameters Using the Declare Statement.
>
> You can do this in your case
> %declare page_input_path `echo $input_path | sed 's/output/output\/page/g'`
>
> Or you can use embedded python (
> http://pig.apache.org/docs/r0.10.0/cont.html#embed-python) to bind the
> input and output after manipulating the parameters using python.
>
> Regards,
> Rohini
>
>
> On Tue, Dec 25, 2012 at 7:35 PM, Mohit Anchlia <mohitanchlia@gmail.com
> >wrote:
>
> > I am trying to replace string in the input parameter. Is something like
> > this possible? I am passing comma separated list of dirs and I have
> several
> > sub dirs that I need to read from individually in those dirs so that
> after
> > loading I can stored them as merged ouput
> >
> >
> > pig -p
> >
> >
> input_path="/user/apuser/web-analytics/flume-output//2012/12/21/13/output,/user/apuser/web-analytics/flume-output//2012/12/21/14/output"
> > new_m.pig
> >
> > %declare page_input_path REPLACE($input_path,"output","output/page")
> >
> > %declare network_input_path
> REPLACE($input_path,"output","output/network")
> >
>

Re: Replacing string in input parameter

Posted by Rohini Palaniswamy <ro...@gmail.com>.
Take a look at http://pig.apache.org/docs/r0.10.0/cont.html#Parameter-Sub-
Specifying Parameters Using the Declare Statement.

You can do this in your case
%declare page_input_path `echo $input_path | sed 's/output/output\/page/g'`

Or you can use embedded python (
http://pig.apache.org/docs/r0.10.0/cont.html#embed-python) to bind the
input and output after manipulating the parameters using python.

Regards,
Rohini


On Tue, Dec 25, 2012 at 7:35 PM, Mohit Anchlia <mo...@gmail.com>wrote:

> I am trying to replace string in the input parameter. Is something like
> this possible? I am passing comma separated list of dirs and I have several
> sub dirs that I need to read from individually in those dirs so that after
> loading I can stored them as merged ouput
>
>
> pig -p
>
> input_path="/user/apuser/web-analytics/flume-output//2012/12/21/13/output,/user/apuser/web-analytics/flume-output//2012/12/21/14/output"
> new_m.pig
>
> %declare page_input_path REPLACE($input_path,"output","output/page")
>
> %declare network_input_path REPLACE($input_path,"output","output/network")
>