pig tutorial - apache pig tutorial - Apache Pig - SecondsBetween() - pig latin - apache pig - pig hadoop
What is SecondsBetween() Function?
- SecondsBetween returns the number of whole seconds between ANow and AThen.
- This means the fractional part of a second (milliseconds etc.) is dropped.
Learn apache pig - apache pig tutorial - Apache-Pig-SecondsBetween - apache pig examples - apache pig programs
SecondsBetween() function in Apache Pig
This function accepts two date-time objects and calculates the number of seconds between the two given date-time objects.
Syntax
Here is the syntax of the SecondsBetween() function.
Example
- Ensure that we have a file named wikitechy_doj_dob.txt in the HDFS directory /pig_data/.
- This file contains the date-of-birth and date-of-joining details of a particular person, id, dateof-birth and date-of-joining.
wikitechy_doj_dob.txt
- We have loaded this file into Pig with a relation named doj_dob_data as shown below.
- Now you can calculate the number of seconds between date-of-birth and date-of-joining of the employees using the SecondsBetween() function as shown below.
Verification
Verify the contents of the relation using the Dump operator as shown below.
Output
- The above statement stores the result in the relation named secondsbetween_data.