Hive timestamp format

走远了吗. 提交于 2020-07-19 11:07:44

问题


I have some data with the following format:

28/04/2017 00:00:00|20550|22/05/2017 00:00:00|

I am setting | as a separator. For the data in the first and third row in this example, I put timestamp as a data type in HUE, but I get nulls as answer.

I have looked around and it seems to me like Hive supports Unix format timestamp (from places like this )

But, I get a "Invalid date" message (I'm doing it with HUE so far, I'm still new with this technologies). If I try to make this data String, I can see values, but when I try to use to_date() the problem persists.

Is there anything I'm ignoring?


回答1:


The only supported timestamp format is yyyy-MM-dd HH:mm:ss with optional fraction of seconds.
Anything else should be read as string and converted later.

Demo

with t as (select '28/04/2017 00:00:00' as mydate)
select  from_unixtime(to_unix_timestamp (mydate,'dd/MM/yyyy HH:mm:ss'))
from    t

2017-04-28 00:00:00



来源:https://stackoverflow.com/questions/44705050/hive-timestamp-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!