简体   繁体   English

是否可以将新的列分区添加到配置单元中已经存在的分区表中

[英]Is it possible to add new column partition to already existing partitioned table in hive

I have partition table called employee_part.This table is partitioned by hiredate. 我有一个名为employee_part的分区表。该表按hiratedate进行了分区。 It has metadata as given below 它具有如下元数据

在此处输入图片说明

When I tried to add new column partition to the employee_part table Im getting an error saying 当我尝试将新的列分区添加到employee_part表中时,出现错误提示

 ALTER TABLE employee_part ADD PARTITION (gender='M') location 'hdfs://user/hive/warehouse/maprpoc.db/employee_part/hiredate=1985-11-21';

FAILED: SemanticException Partition spec {gender=M} contains non-partition columns 失败:SemanticException分区规范{gender = M}包含非分区列

在此处输入图片说明

Please clarify on this! 请对此进行澄清! Thanks in advance.. 提前致谢..

That is because you have partitioned data on hiredate, but trying add partition on gender column. 那是因为您已按雇用日期对数据进行了分区,但是尝试在“性别”列上添加分区。

Create partition on hiredate ie 在hiratedate创建分区,即

 ALTER TABLE employee_part ADD PARTITION (hiredate='1985-11-21') location 'hdfs://user/hive/warehouse/maprpoc.db/employee_part/hiredate=1985-11-21';

This command can't add a new partition column , you can use it to add a new partition on existing column. 此命令无法添加新的分区列 ,您可以使用它在现有列上添加新的分区。

ALTER TABLE employee_part ADD PARTITION (gender='M') location 'hdfs://user/hive/warehouse/maprpoc.db/employee_part/hiredate=1985-11-21';

For this reason you are getting this message: 因此,您收到以下消息:

FAILED: SemanticException Partition spec {gender=M} contains non-partition columns

It does not mean "add a new column partition called gender which has the data located somewhere". 并不意味着“添加新列的分割称为两性其中有位于某处的数据”。 It means "add a new partition ( read : new data ) on gender ( column ), but gender is not a partition column and this is the error you are getting". 这意味着“在性别(列)上添加新分区(读取:新数据),但是性别不是分区列,这是您遇到的错误”。

ADD PARTITION is really useful on PARTITIONED EXTERNAL TABLES, when new data are available on HDFS, you can add them to the table using it. 在分区外部表上添加分区确实非常有用,当HDFS上有新数据时,您可以使用它将它们添加到表中。

So the answer is no. 所以答案是否定的。 You can't add a new partition column on existing tables. 您不能在现有表上添加新的分区列。

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

相关问题 蜂巢:从现有分区表创建新表 - Hive: Create New Table from Existing Partitioned Table 蜂巢-将数据插入分区表:找不到分区 - Hive - Insert data into partitioned table: partition not found Hive:当插入分区表时,在大多数行中,hive double url-encode分区键列 - Hive: When insert into partitioned table, in most of the rows, hive double url-encode the partition key column 如何在Hive表中添加/编辑分区列的注释? - How to add/edit the comment of a partitioned column in Hive table? 按现有字段分区 Hive 表? - Partition Hive table by existing field? 现有表的配置单元存储和分区 - Hive bucketing and partition for existing table 如何squeop导入将新数据追加到分区的配置单元表中,从而在同一分区列上创建新的分区文件夹? 以下是我的情况 - How to sqoop import append new data into partitoned hive table which creates new partitioned folder on same partitioned column? Below is my scenario Hive:创建分区后使用目录分区的外部表(在 Location 中声明) - Hive: Create External Table Partitioned with directory after partition (declared in Location) 如何将新数据追加到现有的配置单元表 - How to Append new data to already existing hive table Pig:从配置单元表获取数据并将分区添加为列 - Pig: get data from hive table and add partition as column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM