如何将HiveVar作为分区变量通过HIVEVAR的蜂巢分区?

发布于 2025-01-24 12:39:54 字数 1566 浏览 0 评论 0原文

我一直在尝试运行此代码,以将当前的分区从Hive A桌上删除,由于某种原因,它不会从蜂巢台上放下分区。不知道什么是磨损。

Table Name : prod_db.products

desc:
+----------------------------+-----------------------+-----------------------+--+
|          col_name          |       data_type       |        comment        |
+----------------------------+-----------------------+-----------------------+--+
| name                       | string                |                       |
| cost                       | double                |                       |
| load_date                  | string                |                       |
|                            | NULL                  | NULL                  |
| # Partition Information    | NULL                  | NULL                  |
| # col_name                 | data_type             | comment               |
|                            | NULL                  | NULL                  |
| load_date                  | string                |                       |
+----------------------------+-----------------------+-----------------------+--+

## I am using the following code

SET hivevar:current_date=current_date();

ALTER TABLE prod_db.products DROP PARTITION(load_date='${current_date}');


Before and After picture of partitions:
+-----------------------+--+
|       partition       |
+-----------------------+--+
| load_date=2022-04-07  |
| load_date=2022-04-11  |
| load_date=2022-04-18  |
| load_date=2022-04-25  |
+-----------------------+--+

它运行没有任何错误,但行不通,但不会放下分区。表是内部/管理的。 我尝试了堆栈上提到的不同方法,但它对我不起作用。 帮助。

I have been trying to run this piece of code to drop current day's partition from hive a table and for some reason it does not drop the partition from the hive table. Not sure what's worng.

Table Name : prod_db.products

desc:
+----------------------------+-----------------------+-----------------------+--+
|          col_name          |       data_type       |        comment        |
+----------------------------+-----------------------+-----------------------+--+
| name                       | string                |                       |
| cost                       | double                |                       |
| load_date                  | string                |                       |
|                            | NULL                  | NULL                  |
| # Partition Information    | NULL                  | NULL                  |
| # col_name                 | data_type             | comment               |
|                            | NULL                  | NULL                  |
| load_date                  | string                |                       |
+----------------------------+-----------------------+-----------------------+--+

## I am using the following code

SET hivevar:current_date=current_date();

ALTER TABLE prod_db.products DROP PARTITION(load_date='${current_date}');


Before and After picture of partitions:
+-----------------------+--+
|       partition       |
+-----------------------+--+
| load_date=2022-04-07  |
| load_date=2022-04-11  |
| load_date=2022-04-18  |
| load_date=2022-04-25  |
+-----------------------+--+

It runs without any error but doesn't work but won't drop the partition. Table is internal/managed.
I tried different ways mentioned on stack but it is just not working for me.
Help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走就滚别墨迹 2025-01-31 12:39:54

您无需设置变量。您可以使用直接SQL直接掉落。

Alter table prod_db.products
drop partition (load_date= current_date());

You dont need to set a variable. You can directly drop using direct sql.

Alter table prod_db.products
drop partition (load_date= current_date());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文