问题描述
我正在与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 (将#修改为@)