pig tutorial - apache pig tutorial - Apache Pig CurrentTime() Function - pig latin - apache pig - pig hadoop

What is CurrentTime() Function in Apache Pig ?

  • The CurrentTime() function is used to generate the DateTime object of the current time.
  • The CurrentTime() function will returns the current time in the number of seconds
  • The CurrentTime() functions are used to interact with system time routine and also format the time outputs which are displayed.
 Apache Pig Currenttime  Function

Learn Apache Pig - Apache Pig tutorial - Apache Pig Currenttime Function - Apache Pig examples - Apache Pig programs


grunt> CurrentTime() 


  • Ensure that we have a file named wikitechy_date.txt in the HDFS directory /pig_data/.
  • This file contains the date-of-birth details of a particular person, id, date, and time.


101,1989/09/26 09:00:00
102,1980/06/20 10:22:00
103,1990/12/19 03:11:44 
  • We have loaded the file into Pig with a relation name called date_data which is given below:
grunt> date_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_date.txt' USING PigStorage(',')
as (id:int,date:chararray)
  • We are generating the current time for the data which is given.
grunt> currenttime_data = foreach todate_data generate CurrentTime();


  • We need to verify the content of the relation by using the Dump operator.
grunt> Dump currenttime_data;


  • The above statement stores the result in the relation named currenttime_data.

Related Searches to Apache Pig CurrentTime() Function