已将日期字符串转换为时间戳,现在无法在配置单元中执行时间戳数学

zd287kbt  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(233)

我有一个Hive表如下:

incident_id      string
incident_time    timestamp
call_id          string 
call_time        timestamp

我最初使用

cast(from_unixtime(unix_timestamp(incident_time, 'yyyy-MM-dd hh:mm:ss')) as timestamp) as incident_time

我做了一个快速选择,它们看起来都不错。我正在查找哪些记录的事件时间介于通话前1小时到通话后48小时之间。我的问题是:

select * from mydb.mytable where 
(incident_time >= call_time-3600) and  
(incident_time <= call_time+172800);

这会引发一个错误,失败时出现异常java.io.ioexception:java.lang.runtimeexception:配置单元2内部错误:不支持从类型转换:interval\u day\u time

mlmc2os5

mlmc2os51#

我通过在hive中使用datediff函数来解决这个问题。

select distinct * 
from 
mydb.mytable  
where 
datediff(incident_time, call_time) <= 1;

找到答案https://issues.apache.org/jira/browse/hive-12729

相关问题