如何在Hive中获取当前的unix时代

问题描述 投票:0回答:1

这是unix_timestamp()提供的功能,但已被弃用。

select unix_timestamp() from table_name limit 1;
unix_timestamp(void) is deprecated. Use current_timestamp instead.
OK
1553706841

它建议使用current_timestamp(),但它没有给出纪元时间:

select current_timestamp() from table_name limit 1;
OK
2019-03-27 13:14:21.767

获取当前unix纪元时间的推荐方法是什么?

hive hiveql epoch
1个回答
1
投票

您可以将unix_timestamp与字符串格式的日期时间/日期参数一起使用以获取纪元。

select unix_timestamp(current_timestamp())

请注意,自2.0版以来,不推荐使用没有参数的unix_timestamp函数,而不是unix_timestamp(string date)

© www.soinside.com 2019 - 2024. All rights reserved.