- Apache Pig Tutorial
- Apache Pig - Home
- Pig Latin
- Pig Latin - Basics
- Diagnostic Operators
- Apache Pig - Diagnostic Operator
- Apache Pig - Describe Operator
- Apache Pig - Explain Operator
- Apache Pig - Illustrate Operator
- Grouping & Joining
- Apache Pig - Group Operator
- Apache Pig - Cogroup Operator
- Apache Pig - Join Operator
- Apache Pig - Cross Operator
- Pig Latin Built-In Functions
- Apache Pig - Eval Functions
- Load & Store Functions
- Apache Pig - Bag & Tuple Functions
- Apache Pig - String Functions
- Apache Pig - date-time Functions
- Apache Pig - Math Functions
- Apache Pig Useful Resources
- Apache Pig - Quick Guide
- Apache Pig - Useful Resources
- Apache Pig - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Apache Pig - CurrentTime()
This function is used to generate DateTime object of the current time.
Here is the syntax of CurrentTime() function.
Assume that there is a file named date.txt in the HDFS directory /pig_data/. This file contains the date-of-birth details of a particular person, id, date, and time.
001,1989/09/26 09:00:00 002,1980/06/20 10:22:00 003,1990/12/19 03:11:44
And, we have loaded this file into Pig with a relation named date as shown below.
grunt> date_data = LOAD 'hdfs://localhost:9000/pig_data/date.txt' USING PigStorage(',') as (id:int,date:chararray);
Following is an example of the CurrentTime() function. Here we are generating the current time.
grunt> currenttime_data = foreach todate_data generate CurrentTime();
The result of the statement will be stored in the relation named currenttime_data. Verify the content of this relation using the Dump operator.
grunt> Dump currenttime_data; (2015-11-06T11:31:02.013+05:30) (2015-11-06T11:31:02.013+05:30) (2015-11-06T11:31:02.013+05:30)