Hive查询比较timestamp与unix_timestamp()报ParseException错误求助
解决Hive查询ParseException的思路
针对你遇到的FAILED: ParseException错误,以下是几个可行的排查和解决方向:
给计算表达式添加括号
解析器可能对运算符优先级的处理存在歧义,给where子句中的计算式加上括号,明确计算顺序:select myInfo from my_table where _timestamp > (unix_timestamp() * 1000 - 3000) and _timestamp < (unix_timestamp() * 1000)统一运算符前后的空格
确保比较运算符(>、<)前后只有一个空格,避免连续空格或无空格的情况,修改后的语句示例:select myInfo from my_table where _timestamp > unix_timestamp() * 1000 - 3000 and _timestamp < unix_timestamp() * 1000提前计算当前时间戳
通过子查询先算出当前毫秒级时间戳,再在where子句中引用,减少解析器的复杂表达式处理压力:select myInfo from my_table cross join (select unix_timestamp() * 1000 as current_ms) t where _timestamp > t.current_ms - 3000 and _timestamp < t.current_ms排查隐藏特殊字符
若语句是复制粘贴而来,可能包含不可见的特殊字符,导致解析失败。尝试手动重新输入整个查询语句,再执行测试。
内容的提问来源于stack exchange,提问作者Jasmine Rice
相关产品推荐
相关产品推荐

