动态分区插入表时在move task阶段报错
insert overwrite table partition (dt) select * from original_table;
Tez报错:
ERROR : Vertex failed, vertexName=Map 28, vertexId=vertex_1709519877882_101279_2_22, diagnostics=[Vertex vertex_1709519877882_101279_2_22 [Map 28] killed/failed due to:ROOT_INPUT_INIT_FAILURE, Vertex Input: *** initializer failed, vertex=vertex_1709519877882_101279_2_22 [Map 28], org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs://oceanhdp/warehouse/tablespace/managed/hive/***.db/***/dt=2020-09
通过show partitions查看该表的分区与hdfs上的文件不一致,元数据这边有2020-09分区,但hdfs不存在,所以在插入的时候找不到这个目录导致的失败。
解决办法:
1.手动删掉hdfs中不存在的分区,分区较多的情况下比较麻烦
2.将数据插入一张临时表然后再更换表名
- 重新创建一张表结构跟目标表一致的表
create table tmp like origianl_table;
- 然后将数据动态写入这张表
insert overwrite table tmp partition(dt) select * from original_table;
3. 最后修改表名
alter table original_table rename to original_table_bak;
alter table tmp rename to original_table;