配置单元-在配置单元sql中将历元时间(毫秒-13位)转换为时间戳,直到毫秒

配置单元-在配置单元sql中将历元时间(毫秒-13位)转换为时间戳,直到毫秒,sql,hive,hiveql,hortonworks-data-platform,epoch,Sql,Hive,Hiveql,Hortonworks Data Platform,Epoch,我需要从配置单元查询中的历元时间戳中获取完整的时间戳 For example epoch time --- 1606407266850 timestamp value --- 2020-11-26 21:44:26 expected value --- 2020-11-26 21:44:26.850 我在hive中的方法: Select timestamp(concat(from_unixtime(CAST(lastModifiedOn AS BIGINT),'yyyy-MM-

我需要从配置单元查询中的历元时间戳中获取完整的时间戳

For example 
epoch time      --- 1606407266850
timestamp value --- 2020-11-26 21:44:26 
expected value  --- 2020-11-26 21:44:26.850
我在hive中的方法:

Select timestamp(concat(from_unixtime(CAST(lastModifiedOn AS BIGINT),'yyyy-MM-dd HH:mm:ss'),".",CAST(lastModifiedOn AS BIGINT)%1000),'yyyy-MM-dd HH:mm:ss.SSS')
from db.table1
我的问题:我们是否有更好的方法获取时间戳值直到毫秒?我们可以很容易地得到价值,直到第二

select cast(lastModifiedOn/1000 as timestamp);

无法指定精度,但会将时间戳保持在最高精度

谢谢mck,请在下面的注释中找到选择cast(cast('1606407266850'作为BIGINT)/1000作为timestamp)ms,--以ms(2020-11-26 16:14:26.85)cast(cast('1606476624'作为BIGINT)作为timestamp)秒给出正确的结果;--错误的结果(1970-01-19 14:14:36.624)我们能做些什么关于历元时间的事吗?秒标准历元时间是以秒为基础的。您的非标准历元时间1606407266850以毫秒为单位,但1606476624以秒为单位。除非在