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

Syntax

grunt> CurrentTime() 

Example

  • 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.

wikitechy_date.txt

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();

Verification

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

Output

  • The above statement stores the result in the relation named currenttime_data.
(2017-09-01T11:31:02.013+05:30)
(2017-09-01T11:31:02.013+05:30) 
(2017-09-01T11:31:02.013+05:30) 

Related Searches to Apache Pig CurrentTime() Function