我有以下形式的字符串数据 2020-10-21 12:49:27.090
我想将其作为时间戳记。当我这样做时:select cast(column_name as timestamp) as column_name from table_name
所有毫秒都将被丢弃,如下所示: 2020-10-21 12:49:27
我也尝试过这个: select cast(date_format(column_name,'yyyy-MM-dd HH:mm:ss.SSS') as timestamp) as column_name from table_name
并且同样的问题仍然存在,它降低了毫秒数。
如何在不损失毫秒的情况下将字符串转换为时间戳?
在Hive 2.3.6的Qubole和demo.gethue.com上进行了测试,效果很好:
select cast ('2020-10-21 12:49:27.090' as timestamp),
timestamp('2020-10-21 12:49:27.090')
结果:
2020-10-21 12:49:27.09 2020-10-21 12:49:27.09
和这个
cast(date_format('2020-10-21 12:49:27.090','yyyy-MM-dd HH:mm:ss.SSS') as timestamp)
也一样。
您的客户端应用程序或Hive版本似乎有问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句