正常分区 PRovince_id=125 动态分区时产生的错误分区(因为有特殊字符,不能直接用hive语句删除) province_id=%2Ffile.cdn.mvideo.xiaomi.com%2Fmobilevideo%2F10001%2F1%2F1d1f7ca81b61a497c1b216b0753dc345.apk
解决方法
1 进入hive使用的MySQL 2 切换为hive数据库
mysql> use hive;3 查询相关表
mysql> SELECT * FROM TBLS WHERE TBL_NAME='o_cu_pm_userdev_url';结果 发现出现两条记录,因为表名有相同的,所以使用TBLS表的SD_ID字段去SDS表查询LOCATION字段的值,通过LOCATION字段,就可以知道o_cu_pm_userdev_url这张表的数据库,TBLS中TBL_ID为70的这行记录就是我要查询的表的ID
mysql> select * from SDS where SD_ID=639;接下来,要根据TBLS表的TBL_ID和hive表分区字段的值(模糊查询)去PARTITIONS表查询,需要得到PARTITIONS表的PART_ID的值(202354)
mysql> select * from PARTITIONS t where t.tbl_id=70 and PART_NAME like '%cdn.mvideo.xiaomi.com%';结果
最后,通过TBLS表的TBL_ID(70)和PARTITIONS表的PART_ID(202354)就可以删除hive的分区了
mysql> delete from PARTITION_KEY_VALS where part_id=202354;Query OK, 6 rows affected (0.01 sec)mysql> delete from PARTITION_PARAMS where part_id=202354;Query OK, 6 rows affected (0.00 sec)mysql> delete from PARTITIONS where tbl_id=70 and part_id=202354;Query OK, 1 row affected (0.01 sec)4 删除HDFS上分区对应的目录【Hive外部表需要此操作】(目录要用双引号括起来,因为目录里有特殊字符)
hdfs dfs -rm -r "/user/hive/bigdata/o_cu_pm_userdev_urlprovince_id=%2Ffile.cdn.mvideo.xiaomi.com%2Fmobilevideo%2F10001%2F1%2F1d1f7ca81b61a497c1b216b0753dc345.apk"新闻热点
疑难解答