1.首先建立一个有分区的外部表
create external table `test_boolean`(
`id` int,
`bool` boolean )partitioned by (
`year` int,
`month` int,
`day` int)
location 'hdfs://...../test_boolean';
2.往分区表中插入值
insert into table test_boolean partition(year=2017,month=4,day=1) values(1,1);
结果 显示: 1 ture 2017 4 1
3. alter table test_boolean change bool bool int;
结果 展示: 1 1 2017 4 1
4.
再往同样的 分区表 插入值
insert into table test_boolean partition(year=2017,month=4,day=1) values(2,1);
结果 显示: 1 1 2017 4 1
2 null 2017 4 1
在另一个分区表 插入值
insert into table test_boolean partition(year=2017,month=4,day=2) values(3,1);
结果 显示: 1 1 2017 4 1
2 null 2017 4 1
3 1 2017 4 2
5.执行 alter table test_boolean change bool bool boolean cascade;
结果显示 :1 ture 2017 4 1
2 null 2017 4 1
3 null 2017 4 1
6.执行alter table test_boolean change bool bool int cascade;
结果显示: 1 null 2017 4 1
2 1 2017 4 1
3 1 2017 4 2
总结:boolean 类型的alter 操作
不像 string 与 int 历史数据和新增数据可以保持一致 有值的
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL