- Apache Pig 教程
- Apache Pig - 首頁
- Apache Pig 簡介
- Apache Pig - 概述
- Apache Pig - 架構
- Apache Pig 環境
- Apache Pig - 安裝
- Apache Pig - 執行
- Apache Pig - Grunt Shell
- Pig Latin
- Pig Latin - 基礎
- 載入與儲存運算子
- Apache Pig - 讀取資料
- Apache Pig - 儲存資料
- 診斷運算子
- Apache Pig - 診斷運算子
- Apache Pig - Describe 運算子
- Apache Pig - Explain 運算子
- Apache Pig - Illustrate 運算子
- Pig Latin 內建函式
- Apache Pig - 評估函式
- 載入與儲存函式
- Apache Pig - Bag 和 Tuple 函式
- Apache Pig - 字串函式
- Apache Pig - 日期時間函式
- Apache Pig - 數學函式
- Apache Pig 有用資源
- Apache Pig - 快速指南
- Apache Pig - 有用資源
- Apache Pig - 討論
Apache Pig - CurrentTime() 函式
此函式用於生成當前時間的DateTime物件。
語法
以下是CurrentTime()函式的語法。
grunt> CurrentTime()
示例
假設在HDFS目錄/pig_data/中有一個名為date.txt的檔案。此檔案包含特定人員的出生日期詳細資訊,包括ID、日期和時間。
date.txt
001,1989/09/26 09:00:00 002,1980/06/20 10:22:00 003,1990/12/19 03:11:44
並且,我們已使用名為date的關係將此檔案載入到 Pig 中,如下所示。
grunt> date_data = LOAD 'hdfs://:9000/pig_data/date.txt' USING PigStorage(',')
as (id:int,date:chararray);
以下是CurrentTime()函式的示例。在這裡,我們正在生成當前時間。
grunt> currenttime_data = foreach todate_data generate CurrentTime();
語句的結果將儲存在名為currenttime_data的關係中。使用 Dump 運算子驗證此關係的內容。
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)
apache_pig_date_time_functions.htm
廣告