2017-07-02 36 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 
;