我的配置单元表中有一个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
1条答案
按热度按时间n6lpvg4x1#
下面的查询应该有效:
选择unixtime(cast(1393526016039/1000作为bigint),'yyyy-mm-dd hh:mm:ss')作为时间\u unix from slog\u table