这是我的表
hive> show create table pv;
OK
CREATE TABLE `pv`(
`pv` int)
PARTITIONED BY (
`d` date)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://hadoop1:8020/user/hive/warehouse/pv'
TBLPROPERTIES (
'transient_lastDdlTime'='1510813098')
Time taken: 0.135 seconds, Fetched: 14 row(s)
插入一条记录进行测试
hive> insert into table pv partition(d="2017-11-16") values (10);
..
..
hive> select * from pv;
OK
10 2017-11-16
Time taken: 0.228 seconds, Fetched: 1 row(s)
hive> select * from pv where d = "2017-11-16";
OK
10 2017-11-16
Time taken: 0.242 seconds, Fetched: 1 row(s)
hive>
问题是当我尝试删除分区'2017-11-16'时,但属于此分区的数据仍然存在,除非我删除分区'2017-11-17',那么数据我只是插入已经消失,但它应该属于“2017-11-16”..
hive> ALTER TABLE pv DROP PARTITION (d='2017-11-16');
OK
Time taken: 0.124 seconds
hive> select * from pv;
OK
10 2017-11-16
Time taken: 0.212 seconds, Fetched: 1 row(s)
hive> ALTER TABLE pv DROP PARTITION (d='2017-11-18');
OK
Time taken: 0.118 seconds
hive> select * from pv;
OK
10 2017-11-16
Time taken: 0.208 seconds, Fetched: 1 row(s)
hive> ALTER TABLE pv DROP PARTITION (d='2017-11-17');
Dropped the partition d=2017-11-16
OK
Time taken: 0.312 seconds
hive> select * from pv;
OK
Time taken: 0.162 seconds
hive>