pig tutorial - apache pig tutorial - Apache Pig - GetWeek() - pig latin - apache pig - pig hadoop
What is GetWeek() in Apache Pig ?
- The GetWeek() function accepts a date-time object as parameter and returns the current week of the current month from the given date-time object.
- Ensure that we have a file named date.txt in the HDFS directory /pig_data/ as given below.
- This file contains the date-of-birth details of a particular person, it has person id, date and time.
- You have loaded this file into Pig with a relation named date_data as given below.
- An example of the GetWeek() function.
- It will retrive the current week from the given date-time object.
- Hence, we generate the date-time objects of all employees using todate() function as shown below.
- Let us now get the month from the date-of-birth of each employee using GetWeek() and store it in the relation named getweek_data.
Now, verify the contents of the getweek_data relation using the Dump operator.