hive动态分区后多出5个异常分区文件

  • 背景
    分区字段dt为date类型,使用动态分区将四年半的数据按照日分区写入对应的分区中,动态分区后多出五个异常分区
    在这里插入图片描述
    这五个异常分区时string类型,都是空分区,里面没有数据
  • 由于非日期类型影响了BI查询,所以需要将这五个分区删掉
  • 解决方法

1.使用
alter table smartdb.smart_company_daily_dws drop partition(dt=‘F7A5457433’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF80808104’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF80808127’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF808081F5’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘HIVE_DEFAULT_PARTITION’);
命令删除分区,报如下错误
在这里插入图片描述

2.删除这五个分区对应的hdfs文件夹,然后msck repaire table
alter table smartdb.smart_company_daily_dws drop partition(dt=‘F7A5457433’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF80808104’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF80808127’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘FF808081F5’);
alter table smartdb.smart_company_daily_dws drop partition(dt=‘HIVE_DEFAULT_PARTITION’);
msck repair table smartdb.smart_company_daily_dws;
没想到连分区文件夹都不在了,show partitons这五个分区居然还在

3.尝试改变此分区字段的数据类型,然后再drop partition
一开始先
alter table smartdb.smart_company_daily_dws change column dt dt string;
报错
在这里插入图片描述
后来发现更改分区字段的数据类型命令不同,然后使用
ALTER TABLE smartdb.smart_company_daily_dws PARTITION COLUMN (dt string);
成功将分区字段数据类型改为string
然后使用drop partition命令可以删除异常分区

  • 出现新问题

使用
ALTER TABLE smartdb.smart_company_daily_dws PARTITION COLUMN (dt date);
将分区字段数据类型改为date类型的时候报了如下错误
在这里插入图片描述
然后注意到报错信息中有in serial mode几个字
想把hive改为非严格模式再执行类型转换,但是失败了
解决方案见
https://blog.csdn.net/weixin_42913992/article/details/124827902?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22124827902%22%2C%22source%22%3A%22weixin_42913992%22%7D&ctrtid=GYXnr

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值