gpt4 book ai didi

hadoop - 插入到配置单元分区表中 SemanticException

转载 作者:可可西里 更新时间:2023-11-01 15:01:56 25 4
gpt4 key购买 nike

首先我创建了一个 Hive 分区表:

hive> create table partition_table
> (sid int ,sname string ,age int)
> partitioned by (sex string)
> row format delimited fields terminated by',';
OK
Time taken: 1.232 seconds

表格描述如下:

 hive> desc partition_table;
OK
sid int
sname string
age int
sex string

# Partition Information
# col_name data_type comment

sex string
Time taken: 0.34 seconds, Fetched: 9 row(s)

然后我将一些数据插入到该表中,但它不起作用。

hive> insert into table partition_table partition(sex='M')select sno ,sname ,age from student1 where sex ='M';
FAILED: SemanticException [Error 10006]: Line 1:44 Partition not found ''M''

为了避免这种情况,我编写了以下命令,然后执行了我的插入命令,即使这样我也反复遇到同样的错误。

set exec.dynamic.partition=true;                                                                           
set exec.dynamic.partition.mode=nonstrict;

最佳答案

加载前添加分区:

ALTER TABLE partition_table ADD PARTITION( sex= 'M' );
insert into table partition_table partition(sex='M') select sno ,sname ,age from student1 where sex ='M';

或尝试动态分区:

set hive.exec.dynamic.partition=true;
INSERT OVERWRITE TABLE partition_table PARTITION (sex)
SELECT sid, sname, age, sex
FROM student1;

关于hadoop - 插入到配置单元分区表中 SemanticException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45357281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com