pig tutorial - apache pig tutorial - Apache Pig GetDay(datetime) Function - pig latin - apache pig - pig hadoop
What is GetDay(datetime)function in Apache Pig ?
- The GetDay(datetime) function will accept a date-time object as a parameter and return the current day of the given date-time object.
- The GetDay() method returns the day of the week for the specified date which is given in GetDay() method.
- The GetDay() gets the day of the month which is represented by this instance.
- Ensure that we have a file named wikitechy_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.
- We have loaded this file into Pig with a relation named date_data as given below.
- Following is an example of the GetDay() function.
- The GetDay() function will retrive the day from the given Date-Time object. So, first of all, let us calculate the date-time objects of all employees using todate() function as shown below.
- Now, get the day from the date-of-birth using GetDay() function and store it in the relation named getday_data.
- Verify the contents of the getday_data relation using the Dump operator.