简体   繁体   中英

Hive query compare timestamp with unix_timestamp() and received error:ParseException missing ' at '>' near '<EOF>'

I try to get the data in the past 3 second by compare the _timestamp and unix_timestamp() but got the error:

Error while compiling statement: FAILED: ParseException line 16:15 missing ' at '>' near '' line 17:16 missing ' at '<' near ''

select myInfo
from my_table
where _timestamp > unix_timestamp() * 1000 - 3000
and _timestamp  < unix_timestamp() * 1000

_timestamp looks like this "1674169604292" and it is epoch time in millisecond format. I know unix_timestamp() gives you epoch time in second format, that is why * 1000.

在此处输入图像描述

I have no clue what is missing based on the error message. Can anyone share some insight? Thank you.

You have to enclose _timestamp with backtick(`). Its not an issue with epoch timestamp.
Use below SQL -

select myInfo
from my_table
where `_timestamp` > unix_timestamp() * 1000 - 3000
and `_timestamp`  < unix_timestamp() * 1000

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM