pig tutorial - apache pig tutorial - Apache Pig GetHour(datetime) Function - pig latin - apache pig - pig hadoop
What is GetHour(datetime) Function in Apache Pig ?
- This function accepts a date-time object as parameter and returns the current hour of the current day of a given date-time object.
- The GetHour() method will returns the hour of the specified date and time.
- The function getHour() method will returns the hour in the specified date which is done according to local time.
Syntax
Example
- Ensure that we have a file named wikitecky_date.txt in the HDFS directory /pig_data/ as given below.
- This file contains the date-of-birth details of a particular person, id, date, and time.
wikitechy_date.txt
- We have loaded the file into Pig with a relation name called date_data which is given below:
- Following is an example of the GetHour() function.
- The GetHour() function will retrive the hour of the day from the given Date-Time object.
- Hence, you can generate the Date-Time objects of all employees using todate() function.
- We will get the hour from the birth time of the employees which is done using GetDay() function and store it in the relation named called gethour_data.