【问题标题】:Errors in converting timstamp to hive format in hive在 hive 中将时间戳转换为 hive 格式时出错
【发布时间】: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


    【解决方案1】:

    下面的查询应该可以工作:

    select from_unixtime (cast (1393526016039/1000 as bigint), 'YYYY-MM-dd HH:mm:SS') as time_unix 来自slog_table

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多