2015-10-16 57 views
0

這與Apache Hive分區問題有關。表創建後的Hive分區和新屬性介紹

創建分區表後請幫助我添加新的屬性添加。 新的屬性數據未加載。

有什麼我們需要調整的?

數據:

header: id, name, date, sal 

dummy.txt 
--------- 

1,Narayana,20150201,20.345 
2,Narayana1,20150202,23.654 
3,Narayana2,20150203,776.23 
4,Narayana3,20150204,23.224 
5,Narayana4,20150205,77.88 
6,Narayana5,20150206,99.765 

DDL

create schema nari; 
use nari; 

drop table x_1; 
create external table x_1(
    id int 
,name string 
,dt string 
,sal double) 
ROW FORMAT DELIMITED 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
LOCATION '/user/hdpcsc/data'; 

drop table p_emp; 
create table p_emp(
    id int 
,name string 
,dt string) 
partitioned by(fp string) 
CLUSTERED BY (id) SORTED BY (id asc) INTO 256 BUCKETS 
STORED AS ORC TBLPROPERTIES("orc.compress"="SNAPPY"); 

insert1

insert overwrite table p_emp partition(fp="Q1FY15") 
select id, name, dt from x_1; 

選擇

select * from p_emp; -- works well 

insert2

insert overwrite table p_emp partition(fp="FCQ116") 
select id, name, dt from x_1; 

選擇

select * from p_emp; -- works well 

現在增加新的屬性

alter table p_emp add columns (sal double); 

insert4

insert overwrite table p_emp partition(fp="Q1FY15") 
select id, name, dt, sal from x_1; 

選擇

select * from p_emp; -- sal attr null data 

insert5

insert overwrite table p_emp partition(fp="FCQ116") 
select id, name, dt, sal from x_1; 

選擇

select * from p_emp; -- sal attr null data 
+0

當您從普通表格x_1中選擇時,您是否獲得薪水值? – madhu

+0

是的,我從x_1獲得值'hive(nari)> select *; 確定 x_1.id x_1.name x_1.dt x_1.sal 1 Narayana 20150201 20。取345 2 Narayana1 20150202 23.654 3 Narayana2 20150203 776.23 4 Narayana3 20150204 23.224 5 Narayana4 20150205 77.88 6 Narayana5 20150206 99.765 時間:0.068秒,抓取時間:6行(多個)' –

回答

0

你可以嘗試下面的查詢,添加列和執行插入如果使用hive0.14.0:

alter table p_emp partition(fp="Q1FY15") add columns (sal double); 
alter table p_emp partition(fp="FCQ116") add columns (sal double); 

你所面臨的問題是蜂巢的錯誤(HIVE- 6131)在0.11.0,0.12.0和0.13.0版本中。

如果在執行上述alter語句時出現錯誤,請嘗試刪除分區並再次插入數據。希望這有助於......

+0

這是改變DDL語法錯誤 –

+0

分區子句將在hive0.14.0及更高版本中提供 – madhu