where子句在当前日期后24个月出现问题

iyfjxgzm  于 2021-06-25  发布在  Hive
关注(0)|答案(1)|浏览(277)

我有一个where子句,它在 Impala 中运行良好,但在Hive中抛出了一个错误。我要做的是只在当天24个月前引入数据。

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

只会出错,不会产生任何结果。

7jmck4yq

7jmck4yq1#

与 Impala 不同,Hive没有 now() 功能。它通过提供 current_date 以及 current_timestamp 寄存器(从版本1.2[ref]开始)。所以对于Hive来说,这应该是可行的:

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

相关问题