g1 = LOAD 'data/grptest' USING PigStorage(',') AS ( a, b , c, d);
r = FOREACH g1 GENERATE
'$myconstant' as constant,
a
;
when called like this:
pig [-x local] -param myconstant=zz <script name>
the output looks like this:
(zz,3)
(zz,5)
(zz,2)
(zz,7)...
On Wed, Oct 20, 2010 at 1:00 PM, John Hui <[email protected]> wrote:
> Hi,
>
> I have this pig script.
>
> 1 data = LOAD '$INPUT' USING PigStorage(',') AS (app:chararray,
> user:chararray , timestamp:int, duration:int);
> 2
> 3 appUserIn = FOREACH data GENERATE app, user;
> 5 distinctAppUserIn = DISTINCT appUserIn;
> 6
> 7 groupOnApp = GROUP distinctAppUserIn BY app;
> 8
> 9 result = FOREACH groupOnApp GENERATE group, COUNT(distinctAppUserIn);
> 10
> 11 STORE result INTO '$OUTPUT' USING PigStorage();
>
> I would like to add a constant to the output such a a timestamp pass into
> the pig script. So idealy I could do FOREACH groupOnApp GENERATE group,
> COUNT(distinctAppUserIn), *'time_constant'*;
>
> Is this possible in Pig?
>
> thanks,
>
> John
>
--
Konstantin Ignatyev
PS: If this is a typical day on planet earth, humans will add fifteen
million tons of carbon to the atmosphere, destroy 115 square miles of
tropical rainforest, create seventy-two miles of desert, eliminate between
forty to one hundred species, erode seventy-one million tons of topsoil, add
2,700 tons of CFCs to the stratosphere, and increase their population by
263,000
Bowers, C.A. The Culture of Denial: Why the Environmental Movement Needs a
Strategy for Reforming Universities and Public Schools. New York: State
University of New York Press, 1997: (4) (5) (p.206)