2
votes

I need to append a value to a declared variable in PIG.

%declare DESC 'Test/nimmiv/pig'

raw = LOAD 'test.log' USING PigStorage('\t') AS (a1:chararray, a2:chararray, a3:long);

/* Do any PIG processing */

value = FOREACH raw GENERATE $0;

TMP = FOREACH raw GENERATE $1 AS path;

PATH = distinct TMP;

/* dump PATH would give me just (tmp) , I need to append this value to the exisitng value Test/nimmiv/pig=>Test/nimmiv/pig/tmp */

STORE value INTO '$DESC/$PATH';

This is throwing undefined alias error. What is the easiest way to append this value to the existing path.

2
Could you provide some sample input and the desired output? - LiMuBei
So the sample is same as my question say i/p=>%declare DESC 'Test/nimmiv/pig' = > o/p => /Test/nimmi/pig/path_0203 where path _0203 is a value obtained in an intermediate pig step. - nnc
So you want to dynamically create output paths using Pig? That doesn't really work. Only that thing comes to mind is the Multistorage (pig.apache.org/docs/r0.8.1/api/org/apache/pig/piggybank/storage/…), but don't know if that is still a thing in Pig. - LiMuBei

2 Answers

1
votes

The undefined alias is "value" which doesn't seem to have been introduced before and would have to already exist before you attempted a STORE on it.

0
votes

You can use UNION as described at http://pig.apache.org/docs/r0.14.0/basic.html#union.

Example:

combined = UNION value, path;