Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
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!