场景:
今天在删除一个表分区数据的时候,直接删除的HDFS对应目录下的文件 ds=20230614
image.png
就是hdfs的数据删除了,使用show partitions tablename
发现该分区还存在,hive的metastore却没有更新,
- 查阅资料发现hive的msck命令只能修复新增的分区
msck repair table tablename;
- 可以使用以下命令解决
alter table tableneme drop partition(ds='20230614')
对应有条件清理对应分区的,可以使用规则判断,或者正则
alter table tableneme drop partition(ds<'20230614')