CASCADE:官网解释级联,不太好理解,直接通过举例说明
create table wyf_test(id int,name string) partitioned by (dt string);
insert into table wyf_test partition(dt = '2019-11-13') select 1,'zhangsan';
insert into table wyf_test partition(dt = '2019-11-14') select 2,'lisi';
select * from wyf_test where dt = '2019-11-13';
alter table wyf_test add columns(sex string) CASCADE;
insert into table wyf_test partition(dt = '2019-11-13') select 1,'zhangsan','male';
insert into table wyf_test partition(dt = '2019-11-14') select 2,'lisi','female';
insert into table wyf_test partition(dt = '2019-11-15') select 3,'wangwu','female';
select * from wyf_test;
结果:
create table wyf_test(id int,name string) partitioned by (dt string);
insert into table wyf_test partition(dt = '2019-11-13') select 1,'zhangsan';
insert into table wyf_test partition(dt = '2019-11-14') select 2,'lisi';
select * from wyf_test where dt = '2019-11-13';
alter table wyf_test add columns(sex string) ;
insert into table wyf_test partition(dt = '2019-11-13') select 1,'zhangsan','male';
insert into table wyf_test partition(dt = '2019-11-14') select 2,'lisi','female';
insert into table wyf_test partition(dt = '2019-11-15') select 3,'wangwu','female';
select * from wyf_test;
结果:
不加CASCADE,往已存在的分区中插入新增字段值时,为空。
加了CASCADE,往已存在的分区中插入新增字段值时,有值。