2015-10-16 35 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