Hive版本1.1
我有一个如下所示的外部表:
CREATE EXTERNAL TABLE `schedule_events`(
`schedule_id` string COMMENT 'from deserializer',
`service_key` string COMMENT 'from deserializer',
`event_start_date_time` string COMMENT 'from deserializer',
`event_id` string COMMENT 'from deserializer',
`event_type` string COMMENT 'from deserializer',
`transitional_key` string COMMENT 'from deserializer',
`created_date_time` string COMMENT 'from deserializer',
`bus_date` string COMMENT 'from deserializer')
PARTITIONED BY (
`year` string,
`month` string,
`day` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
LOCATION
'hdfs://nameservice1/hadoop/raw/omega/scheduled_events'
TBLPROPERTIES (
'avro.schema.url'='hdfs:////hadoop/raw/omega/schema/schedule_events.avsc',
'transient_lastDdlTime'='1505742141')
现在,我可以运行以下 ALTER 命令来删除特定的分区:
ALTER TABLE schedule_events DROP IF EXISTS PARTITION (year='2016',month='06',day='01')
Dropped the partition year=2016/month=06/day=01
hive> show partitions schedule_events;
OK
year=2017/month=09/day=01
year=2017/month=09/day=02
year=2017/month=09/day=03
year=2017/month=09/day=04
year=2017/month=09/day=05
但是这个表有很多分区。
我该如何一次性删除所有现有的分区?我想一次性删除所有现有的分区,这可能吗?
ALTER TABLE schedule_events DROP IF EXISTS PARTITION (year is not null)
- AmbrishALTER TABLE schedule_events DROP IF EXISTS PARTITION (year is not null)
会检查是否存在一个名为year is not null
的分区,而这是错误的。 - Ani Menon