【问题标题】:Trouble with a where clause which looks back 24 months from current date从当前日期回溯 24 个月的 where 子句存在问题
【发布时间】:2019-11-12 02:25:40
【问题描述】:

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

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

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

【问题讨论】:

  • throwing an errorerroring out 在没有更多信息的情况下作为问题描述毫无用处。您收到错误消息吗?如果是这样,您收到的确切信息是什么。如果您没有收到错误消息,那么抛出错误具体是什么意思?

标签: hive hiveql impala


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 2018-04-30
    • 1970-01-01
    相关资源
    最近更新 更多