微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在ALTER TABLE DROP PARTITION中使用date_subcurrent_date,x?

如何解决如何在ALTER TABLE DROP PARTITION中使用date_subcurrent_date,x?

我正在与Hive合作,并且试图在滚动期内(过去60天)拥有一张桌子,但是在删除/删除过时的行/分区时遇到了问题。我的桌子上有两个分区 event_date (STRING)和 brand (STRING)。

我第一次尝试

alter table northamerica_websites_last60 drop IF EXISTS partition (event_date < date_sub(current_date,61),brand="MLN");

但是我收到错误消息: 无法识别常量附近的'date_sub''((''current_date''

然后尝试使用 hive.exec.dynamic.partition.mode = nonstrict;

SET hive.exec.dynamic.partition.mode=nonstrict;
alter table northamerica_websites_last60 drop IF EXISTS partition (event_date < date_sub(current_date,brand="MLN");

我仍然收到错误消息: 无法识别常量附近的'date_sub''((''current_date''

然后我尝试了变量

SET hive.exec.dynamic.partition.mode=nonstrict;
SET hivevar:DATE_VAR= date_sub(current_date,61);

alter table northamerica_websites_last60 drop IF EXISTS partition (event_date < ${DATE_VAR},brand="MLN");

我仍然收到错误消息: 无法识别常量附近的'date_sub''((''current_date''

最后我尝试了这种方式

SET hive.exec.dynamic.partition.mode=nonstrict;

SET runmdt = date_sub(current_date,91);
alter table northamerica_media_last90 drop IF EXISTS partition (event_date < ${hiveconf:runmdt},brand="MLN");

,但仍然出现错误消息: 无法识别常量附近的“ date_sub”,“(”“ current_date”附近的输入

但是,当我尝试使用字符串时,它可以工作。例如

alter table northamerica_websites_last60 drop IF EXISTS partition (event_date < '2020-07-25',brand="MLN");

如何在alter table drop分区查询中使用date_sub(current_date,91)?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。