简体   繁体   English

如何在蜂巢中删除一周中给定日期的分区

[英]How to drop a partition for given day of a week in hive

Able to drop a partition for a given day of the week ie Thursday, by hardcoding the value. 通过硬编码该值,可以删除一周中给定日期(即星期四)的分区。

ALTER TABLE logs DROP IF EXISTS PARTITION(date=2014-10-30); ALTER TABLE记录DROP IF EXISTS PARTITION(日期= 2014-10-30);

How to drop a partition for last Thursday(date=2014-10-30) with out hardcoding date value? 如何删除上一个星期四(date = 2014-10-30)的分区而没有硬编码日期值?

One way to dynamically pass date to the hiveql statement is by using hive variables, let assume we have hive script named alter.hql and its contents are: 将日期动态传递到hiveql语句的一种方法是使用hive变量,假设我们有一个名为alter.hql hive脚本,其内容为:

alter.hql alter.hql

ALTER TABLE logs DROP IF EXISTS PARTITION (date='${hiveconf:date}');

And you can invoke the alter.hql by passing the date variable to it: 您可以通过将date变量传递给alter.hql来调用它:

hive -hiveconf date='2014-10-30' -f alter.hql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM