簡體   English   中英

插入配置單元分區表SemanticException

[英]Insert into hive partitioned table SemanticException

首先,我創建一個配置單元分區表:

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

表desc如下所示:

 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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM