2017-07-02 38 views
1

我创建使用蜂巢我想分区基于位置分区蜂房数据复合数据类型,同时插入数据其显示错误

create table student(
     id bigint 
    ,name string 
    ,location string 
    , course array<string>) 
ROW FORMAT DELIMiTED fields terminated by '\t' 
collection items terminated by ',' 
stored as textfile; 

和数据的数据等

100 student1 ongole java,.net,hadoop 
101 student2 hyderabad .net,hadoop 
102 student3 vizag java,hadoop 
103 student4 ongole .net,hadoop 
104 student5 vizag java,.net 
105 student6 ongole java,.net,hadoop 
106 student7 neollre .net,hadoop 

创建分区的表表:

create table student_partition(
     id bigint 
    ,name string 
    ,course array<string>) 
PARTITIONED BY (address string) 
ROW FORMAT DELIMiTED fields terminated by '\t' 
collection items terminated by ',' 
stored as textfile; 

INSERT OVERWRITE TABLE student_partition PARTITION(address) select * from student;

我试图划分基于位置的数据,但它显示如下错误:

FAILED: SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different 'address': Cannot convert column 2 from string to array.

请人帮我。

回答

0

源和目标的列应匹配


选项1:调整源到目标。的分配柱进入最后

insert into student_partition partition (address) 
select id,name,course,location 
from student 
; 

选项2:调整目标到源

insert into student_partition partition (address) (id,name,address,course) 
select * 
from student 
; 

P.S.您可能需要这个 -

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