hive分区表增加列
新增的列会以null展示
插入数据后还是显示null,但是在presto中还是能查到数据的,应该是和hive的表结构有关,修改Hive分区表结构以后,元数据库中的SDS中该表对应的CD_ID会改变,但是该表分区下面对应的CD_ID还是原来表的CD_ID。SDS表主要保存文件存储的基本信息,如INPUT_FORMAT、OUTPUT_FORMAT、是否压缩等
所以,要取mysql修改元数据,具体看这里添加链接描述
如果放到第二天的分区,就能查出数据
后来看到官方说hive分区表在加字段时要加一个cascade
alter table test add columns(fs string comment ‘分数’)cascade;
这要就能生效了
drop table if exists test;
create table test(
`name` string COMMENT '姓名',
`age` string COMMENT '年龄'
) COMMENT '1'
PARTITIONED BY (dt string)
stored as parquet
LOCATION '/warehouse/yizun/dwd/test'
TBLPROPERTIES('parquet.compression'='lzo');
insert into table test partition(dt='2021-06-04') values('zs','15');
#alter table test add columns(fs string comment '分数');
alter table test add columns(fs string comment '分数')cascade;
insert into table test partition(dt='2021-06-04') values('ls','18','99');
insert into table test partition(dt='2021-06-05') values('ww','10','66');