简体   繁体   English

如何重命名配置单元中的所有分区列

[英]How to rename all partition columns in hive

When I am trying to rename all partition columns in an existing table for date range of one year which are partitioned - this is what I am getting.当我尝试为已分区的一年日期范围重命名现有表中的所有分区列时 - 这就是我得到的。

hive> ALTER TABLE test.usage PARTITION ('date') RENAME TO PARTITION (partition_date);

FAILED: ValidationFailureSemanticException Partition spec {partition_date=null} contains non-partition columns.

I got that syntax from here: 1我从这里得到了那个语法: 1

Given that I am not 100% sure if what you want is to rename the value of the partition or actually change the column which the table is partitioned.鉴于我不是 100% 确定您想要的是重命名分区的值还是实际更改表分区的列。

Let's suppose you want to rename the partition's value.假设您要重命名分区的值。

There is an issue in Hive 0.13 and in Hive 0.14 is working fine. Hive 0.13 中存在问题,而 Hive 0.14 中工作正常。 Anyways, this should work:无论如何,这应该有效:

set fs.hdfs.impl.disable.cache=false; 
set fs.file.impl.disable.cache=false; 

Now run the query by setting this property.现在通过设置此属性运行查询。

> hive> set fs.hdfs.impl.disable.cache=false;  
> hive> set fs.file.impl.disable.cache=false;
> hive> ALTER TABLE test.usage PARTITION (date='oldValue') RENAME TO PARTITION (date='newValue');

Let's suppose you want to change the partition column假设您要更改分区列

In this case what you will need to do is to recreate the table changing the column which the table will be partitioned.在这种情况下,您需要做的是重新创建表,更改表将被分区的列。

Note: Remember that if you already had data inside the partitions, you will need to reinsert the data.注意:请记住,如果分区内已有数据,则需要重新插入数据。

Please see also this answer另请参阅此答案

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

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