[英]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.