如何获取PIG中的当前时间戳 [英] How to get the current time stamp in PIG
本文介绍了如何获取PIG中的当前时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对正在编写的PIG脚本有疑问.
I have a query with respect to a PIG script that I am writing.
如何在PIG脚本中获取当前的Unix时间戳?我是否需要任何UDF ..或PIG可以为我提供currnet时间戳?
How can I get the current Unix Time Stamp in PIG script.? Do I need any UDF for the purpose.. or can PIG provide me the currnet time stamp ?
请劝我.谢谢
推荐答案
我要指出两个解决方案
第一个:
使用CurrentTime(),将其转换为ToUnixTime()以获取时间戳.
use CurrentTime(),convert it to ToUnixTime() for need to get timestamp.
Ex:
X = load "xx" ......... ;
X1 = FOREACH X GENERATE ToUnixTime(CurrentTime())
第二个:
从命令行作为参数传递.
Passing from command line as a parameter.
pig -f myscript.pig --param timestamp=$(date +%s)
----in myscript.pig ----
%declare time '$timestamp ';
X1 = FOREACH X GENERATE '$time' ;
这篇关于如何获取PIG中的当前时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文