Mohan.V Mohan.V - 1 year ago 106
Bash Question

How to get EPOCH time in PIG?

I am completely new to pig.
Started to learn on my own and trying to know PIG.
Can anyone please suggest me to get the current system epoch time using pig by reading a words.txt file which having words.

I need the output as

word1_1234567890 word2_1234567890 word3_1234567890

And how can we call the shell script in PIG script

Because I have already written the Shell script.

Any Help.

Thanks in Advance.


Answer Source

Use CONCAT to combine your word with the epochtime.You can get the epochtime using ToUnixTime()

A = LOAD 'words.txt' AS (word:chararray);
B = FOREACH A GENERATE CONCAT(CONCAT(A.word,'_'),(chararray)ToUnixTime(CurrentTime());

Let's say your shell script is names

%declare my_shell_script ''
A = LOAD 'data.txt' AS (f1:int,f2:chararray);
B = FOREACH A GENERATE '$my_shell_script';

If your shell script has parameter say param1

%declare my_shell_script ' $param1'
A = LOAD 'data.txt' AS (f1:int,f2:chararray);
B = FOREACH A GENERATE '$my_shell_script';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download