我用的是Hive1.1
摄取dtm中的最后六位数字表示毫秒。
但是如果我也指定了模式,unix\u timestamp hive函数会给出相同的结果
那么,如何得到包含毫秒的unix\u时间戳的结果呢
select a_ingestion_dtm,unix_timestamp(a_ingestion_dtm) from omega limit 10;
+-----------------------------+-------------+--+
| a_ingestion_dtm | _c1 |
+-----------------------------+-------------+--+
| 2019-07-08 16:11:02.076002 | 1562616662 |
| 2019-07-08 21:07:26.253007 | 1562634446 |
| 2019-07-08 21:07:14.284 | 1562634434 |
+-----------------------------+-------------+--+
select a_ingestion_dtm,unix_timestamp(a_ingestion_dtm,'yyyy-MM-dd HH:mm:ss.SSSSSS') from omega limit 10;
+-----------------------------+-------------+--+
| a_ingestion_dtm | _c1 |
+-----------------------------+-------------+--+
| 2019-07-08 16:11:02.076002 | 1562616662 |
| 2019-07-08 21:07:26.253007 | 1562634446 |
| 2019-07-08 21:07:14.284 | 1562634434 |
+-----------------------------+-------------+--+
1条答案
按热度按时间a0x5cqrl1#
unix\u timestamp(string date)返回从1970年起经过的秒数。
您可以将毫秒部分连接到unix\u timestamp返回的bigint。
就像在这个演示中:
结果: