You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Haitao Yao <ya...@gmail.com> on 2012/07/27 05:32:22 UTC

define global constants in pig script

Hi, all
	I got an idea about a new feature for pig: define global constants in pig script.
	Here's the example like this:

-- define a global constant for storage
define store_location "/where_you_store_result";

-- then all the following constants reference will be replaced in runtime
store Result into $$store_location using PigStorage(',');
 

	so, in this way, we just write the template scripts and import them with the constants defined. A commonly use case is use it to compute data for different days.
	Without this feature, I have to use sed to replace the variables on the template script to generate the daily pig scripts.
	How do you guy think so?


Haitao Yao
yao.erix@gmail.com
weibo: @haitao_yao
Skype:  haitao.yao.final


Re: define global constants in pig script

Posted by Haitao Yao <ya...@gmail.com>.
Yes, this is just what I'm looking for. 
thanks.

Haitao Yao
yao.erix@gmail.com
weibo: @haitao_yao
Skype:  haitao.yao.final

在 2012-7-27,下午5:26, Jonathan Coveney 写道:

> Pig already has this! :)
> http://pig.apache.org/docs/r0.10.0/cont.html#parameter-sub
> 
> Unless I'm really misunderstanding what you mean?
> 
> 2012/7/26 Haitao Yao <ya...@gmail.com>
> 
>> Hi, all
>>        I got an idea about a new feature for pig: define global constants
>> in pig script.
>>        Here's the example like this:
>> 
>> -- define a global constant for storage
>> define store_location "/where_you_store_result";
>> 
>> -- then all the following constants reference will be replaced in runtime
>> store Result into $$store_location using PigStorage(',');
>> 
>> 
>>        so, in this way, we just write the template scripts and import
>> them with the constants defined. A commonly use case is use it to compute
>> data for different days.
>>        Without this feature, I have to use sed to replace the variables
>> on the template script to generate the daily pig scripts.
>>        How do you guy think so?
>> 
>> 
>> Haitao Yao
>> yao.erix@gmail.com
>> weibo: @haitao_yao
>> Skype:  haitao.yao.final
>> 
>> 


Re: define global constants in pig script

Posted by Jonathan Coveney <jc...@gmail.com>.
Pig already has this! :)
http://pig.apache.org/docs/r0.10.0/cont.html#parameter-sub

Unless I'm really misunderstanding what you mean?

2012/7/26 Haitao Yao <ya...@gmail.com>

> Hi, all
>         I got an idea about a new feature for pig: define global constants
> in pig script.
>         Here's the example like this:
>
> -- define a global constant for storage
> define store_location "/where_you_store_result";
>
> -- then all the following constants reference will be replaced in runtime
> store Result into $$store_location using PigStorage(',');
>
>
>         so, in this way, we just write the template scripts and import
> them with the constants defined. A commonly use case is use it to compute
> data for different days.
>         Without this feature, I have to use sed to replace the variables
> on the template script to generate the daily pig scripts.
>         How do you guy think so?
>
>
> Haitao Yao
> yao.erix@gmail.com
> weibo: @haitao_yao
> Skype:  haitao.yao.final
>
>