hive运行 insert overwrite ……select…… 语句时报错如下:
[08S01][1]
Error while processing statement: FAILED: Execution Error, return code 1 from
org.apache.hadoop.hive.ql.exec.MoveTask. Exception when loading 1 in table
ads_shp_balance with
loadPath=hdfs://master:9000/gg_original230720/ads/ads_shp_balance/.hive-staging_hive_2023-08-08_10-07-45_675_1710402502516280752-1/-ext-10000
查看hive的log日志,看到有如下报错内容:
2023-08-08T10:09:09,314 ERROR [load-dynamic-partitions-0] metadata.Hive: Exception when loading partition with parameters partPath=hdfs://master:9000/gg_original230720/ads/ads_shp_balance/.hive-staging_hive_2023-08-08_10-07-45_675_1710402502516280752-1/-ext-10000/date=2021-02-14, table=ads_shp_balance, partSpec={date=2021-02-14}, loadFileType=REPLACE_ALL, listBucketingLevel=0, isAcid=false, hasFollowingStatsTask=true
org.apache.hadoop.hive.ql.metadata.HiveException: Directory hdfs://master:9000/gg_original230720/ads/ads_shp_balance/date=2021-02-14 could not be cleaned up.
……
Caused by: java.io.FileNotFoundException: File hdfs://master:9000/gg_original230720/ads/ads_shp_balance/date=2021-02-14 does not exist.

原因:手动从hdfs上将分区删除,但是hive元数据中的记录还有,造成其实分区里面没有内容不能抽取数据成功。这可以通过show partitions ads_shp_balance进行查看确认。
解决方法:在hive中执行删除分区的操作。
sql如下:
alter table ads_shp_balance drop partition(`date`='2021-04-19');——日期为已删除的分区日期。
删除后再重新执行 insert overwrite ……select…… 语句就正常了。




