How to get the current time stamp in PIG
I am pointing two solutions
first one:
use CurrentTime(),convert it to ToUnixTime() for need to get timestamp.
Ex: X = load "xx" ......... ; X1 = FOREACH X GENERATE ToUnixTime(CurrentTime())
second one:
Passing from command line as a parameter.
pig -f myscript.pig --param timestamp=$(date +%s) ----in myscript.pig ---- %declare time '$timestamp '; X1 = FOREACH X GENERATE '$time' ;
You do need to use a UDF. Good news is that it ships with Pig. It's called CurrentTime
. Take a look at the docs page here for all the built-in functions.