在开发过程中,向hive分区表新增字段,发现查询新增字段的值为NULL
create table student(id int,name string) partitioned by (dt string);
insert into table student partition(dt = '2019-11-13') select 1,'zhangsan';
insert into table student partition(dt = '2019-11-14') select 2,'lisi';
select * from student where dt = '2019-11-13';
select * from student where dt = '2019-11-14';
alter table student add columns(sex string);
insert into table student partition(dt = '2019-11-13') select 1,'zhangsan','male';
insert into table student partition(dt = '2019-11-14') select 2,'lisi','female';
insert into table student partition(dt = '2019-11-15') select 3,'wangwu','female';
select * from student where dt = '2019-11-13';
select * from student where dt = '2019-11-14';
但是 impala查询正常
select * from student where dt = '2019-11-15';
对于在增加字段前已经存在的分区,必须再执行
alter table student paritition(dt = '2019-11-14') add columns(sex string);
select * from student where dt = '2019-11-14';
原文:https://www.cnblogs.com/wuning/p/11867733.html