Created 09-02-2016 09:14 AM
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.
I need the output as
epochtime_1234567890
And how can we call the shell script in PIG script
Because I have already written to get EPOCH time in Shell script.
Any Help.
Thanks in Advance.
Mohan.v
Created 09-02-2016 01:58 PM
Hey Mohan,
It might be cleaner to just write a UDF. I certainly feel like PIG has purposely left this functionality out to encourage the use of datetime over the use of epochs.
Here's one way to achieve what you want to do:
a = load 'test.data'; b = foreach a GENERATE *, CONCAT( 'epochtime_', (chararray)MilliSecondsBetween(CurrentTime(),ToDate(0))) ;dump b;
Hope this helps.
Created 09-02-2016 01:58 PM
Hey Mohan,
It might be cleaner to just write a UDF. I certainly feel like PIG has purposely left this functionality out to encourage the use of datetime over the use of epochs.
Here's one way to achieve what you want to do:
a = load 'test.data'; b = foreach a GENERATE *, CONCAT( 'epochtime_', (chararray)MilliSecondsBetween(CurrentTime(),ToDate(0))) ;dump b;
Hope this helps.
Created 09-02-2016 02:09 PM
Created 09-02-2016 02:21 PM
I think i got it too.
please correct me if im wrong
A = LOAD 'words.txt' AS (word:chararray);
B = FOREACH A GENERATE CONCAT(CONCAT(A.word,'_'),(chararray)ToUnixTime(CurrentTime());
dump B;
Created 09-02-2016 07:50 PM
That Looks better than what I proposed. Thumbs up!