Hive 在配置单元中删除一系列分区

Hive 在配置单元中删除一系列分区,hive,hql,Hive,Hql,我有一个配置单元(版本0.11.0)表,按列日期分区,类型为string。我想知道在配置单元中是否有一种方法可以删除一系列日期的分区(比如从“date1”到“date2”)。我尝试了以下(SQL类型)查询,但它们在语法上似乎不正确: ALTER TABLE myTable DROP IF EXISTS PARTITION (date>='date1' and date<='date2'); ALTER TABLE myTable DROP IF EXISTS PARTITION (

我有一个配置单元(版本0.11.0)表,按列日期分区,类型为string。我想知道在配置单元中是否有一种方法可以删除一系列日期的分区(比如从“date1”到“date2”)。我尝试了以下(SQL类型)查询,但它们在语法上似乎不正确:

ALTER TABLE myTable DROP IF EXISTS PARTITION
(date>='date1' and date<='date2');

ALTER TABLE myTable DROP IF EXISTS PARTITION
(date>='date1' && date<='date2');

ALTER TABLE myTable DROP IF EXISTS PARTITION
(date between 'date1' and 'date2');
altertablemytabledrop(如果存在分区)

(date>='date1'和date='date1'和&date解决方案:
改变表myTable的放置分区(unix_时间戳('date1','yyyyy-MM-dd')>unix_时间戳(myDate,‌​'yyyy-MM-dd'),unix\u t‌​imestamp('date2','yy‌​yy-MM-dd')我尝试了这种语法,它很有效

ALTER TABLE mytable DROP PARTITION (dates>'2018-04-14',dates<'2018-04-16');

我用的是Hive 1.2.1000.2.5.5.0-157,我想这会把所有东西都扔到桌子上?大于201-04-14或小于2018-04-16…@HeinduPlessis这是不是或。例如:日期>'2018-04-14'和dates@HeinduPlessis,不,它不会删除其他分区,它只会删除其中的分区between@vreyespue我认为这两个都是有用的——你的sscript更具动态性,但对于OP(和我的)要求,这个答案更容易应用。@Kharthigeyan事实上我从未意识到它是一个and逻辑。这里是date1、date2和myDate。假设您想在2018-11-01和2019-02-12之间删除?更改表mytable drop分区(myDate>'2018-11-01',myDate<'2019-02-12')
    Dropped the partition dates=2018-04-15/country_id=107
    Dropped the partition dates=2018-04-15/country_id=110
    Dropped the partition dates=2018-04-15/country_id=112
    Dropped the partition dates=2018-04-15/country_id=14
    Dropped the partition dates=2018-04-15/country_id=157
    Dropped the partition dates=2018-04-15/country_id=159
    Dropped the partition dates=2018-04-15/country_id=177
    Dropped the partition dates=2018-04-15/country_id=208
    Dropped the partition dates=2018-04-15/country_id=22
    Dropped the partition dates=2018-04-15/country_id=233
    Dropped the partition dates=2018-04-15/country_id=234
    Dropped the partition dates=2018-04-15/country_id=76
    Dropped the partition dates=2018-04-15/country_id=83
    OK
    Time taken: 0.706 seconds