Hive: Cannot truncate non-managed table

本文介绍了一种增强的Hive语法,允许用户通过使用TRUNCATE TABLE...PARTITION...FORCE命令来释放集群存储空间,特别是针对外部表的数据删除操作。此外,还讨论了如何配置属性hive.truncate.skiptrash来决定数据是否移动到回收站。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In my use case ,
sometimes I have to remove data of external tables to free up storage space of the cluster .
So it's necessary for to enhance the syntax like
"TRUNCATE TABLE srcpart_truncate PARTITION (dt='201130412') FORCE;"
to remove data from EXTERNAL table.

And I add a configuration property to enable remove data to Trash
<property>
<name>hive.truncate.skiptrash</name>
<value>false</value>
<description>
if true will remove data to trash, else false drop data immediately
</description>
</property>

For example :
hive (default)> TRUNCATE TABLE external1 partition (ds='11');
FAILED: Error in semantic analysis: Cannot truncate non-managed table external1
hive (default)> TRUNCATE TABLE external1 partition (ds='11') FORCE;
[2013-04-16 17:15:52]: Compile Start
[2013-04-16 17:15:52]: Compile End
[2013-04-16 17:15:52]: OK
[2013-04-16 17:15:52]: Time taken: 0.413 seconds

hive (default)> set hive.truncate.skiptrash;
hive.truncate.skiptrash=false

hive (default)> set hive.truncate.skiptrash=true;
hive (default)> TRUNCATE TABLE external1 partition (ds='12') FORCE;
[2013-04-16 17:16:21]: Compile Start
[2013-04-16 17:16:21]: Compile End
[2013-04-16 17:16:21]: OK
[2013-04-16 17:16:21]: Time taken: 0.143 seconds

hive (default)> dfs -ls /user/test/.Trash/Current/;
Found 1 items
drwxr-xr-x -test supergroup 0 2013-04-16 17:06 /user/test/.Trash/Current/ds=11

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值