【发布时间】:2014-02-28 18:59:36
【问题描述】:
我的 hive 表中有一个 JSON 数据,其中包含以下格式的时间(以毫秒为单位):
...."internal":{"time":["1393404205891"]....
我想以YYYY-MM-DD HH:MM:SS 格式获取时间,以便稍后查询它以获取仅特定小时持续时间的记录。
我尝试了以下方法,但仍然无法获得所需格式的时间。
第一次尝试:
select from_unixtime(cast(get_json_object(log_json,'$.internal.time[0]') as bigint)/1000, 'YYYY-MM-DD HH:MM:SS') as time_unix
from slog_table
错误:
No matching method for class org.apache.hadoop.hive.ql.udf.UDFFromUnixTime with (double, string)
第二次尝试:
select from_unixtime (cast ('1393526016039' as int)/1000, 'YYYY-MM-DD HH:MM:SS') as time_unix
from slog_table
【问题讨论】:
标签: json datetime hadoop hive unix-timestamp