At work we receive a new file each day that we transfer to hive. the table is partitioned by the column "day
" containing the time the data was transferred to hive in the format of "yyyy-MM-dd
". Whenever a new file is added, we want to drop the previous partitions so that the table only contains the latest file's data. Is there a way to write a HiveQL query to dynamically drop any partition before the current date? I tried :
alter table table_name drop if exists partition (day < current_date);
but I got this error:
FAILED: ClassCastException org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc cannot be cast to org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc."
Is there another way to do this?