我有一个Hive(版本0.11.0)表,按列日期分区,类型为字符串.我想知道在Hive中是否存在一种方法,我可以通过该方式删除一系列日期的分区(例如从'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');
Run Code Online (Sandbox Code Playgroud)
我尝试了这种语法,它起作用了。
ALTER TABLE mytable DROP PARTITION (dates>'2018-04-14',dates<'2018-04-16');
Run Code Online (Sandbox Code Playgroud)
命令输出:
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
Run Code Online (Sandbox Code Playgroud)
我正在使用Hive 1.2.1000.2.5.5.0-157
| 归档时间: |
|
| 查看次数: |
15287 次 |
| 最近记录: |