从当前日期回溯 24 个月的 where 子句出现问题

Trouble with a where clause which looks back 24 months from current date

我有这个 where 子句,它在 Impala 中工作正常,但在 Hive 中抛出错误。我想做的是只引入当天前 24 个月的数据。

select * from my.database
where period_date > add_months(now(), -24);

只是出错,没有产生任何结果。

与 Impala 不同,Hive 没有 now() 函数。它通过提供 current_datecurrent_timestamp 寄存器(从版本 1.2 [ref] 开始)符合 ANSI SQL。所以对于 Hive,这应该有效:

select * from my.database
where period_date > add_months(current_date, -24);