我想从一些日期时间增量中得到毫秒精度。我在hive中没有看到毫秒()函数。
考虑一下:
with t as (
select (CAST(1481652239798 AS TIMESTAMP) - CAST(1481652228576 as timestamp))
as delta
)
select delta from t;
0 00:00:11.222000000
如果我能将输出转换成字符串并提取句点后面的部分,我就可以处理这个问题。
with t as (
select (CAST(1481652239798 AS TIMESTAMP) - CAST(1481652228576 as timestamp))
as delta
)
select instr(delta, '.') from t
11 -- correct index of '.'
因此instr()将delta视为一个字符串,但我不能将其子字符串:
with t as (
select (CAST(1481652239798 AS TIMESTAMP) - CAST(1481652228576 as timestamp))
as delta
)
select substr(delta, 11) from t; -- directly supplying instr() leads to a different bug with parsing the query syntax
No matching method for class org.apache.hadoop.hive.ql.udf.UDFSubstr with (interval_day_time, int)
有解决办法吗?
1条答案
按热度按时间lsmd5eda1#
如果你投下
timestamp
反对double
它保留了这一部分。因此,请尝试以下方法: