[英]drop column from a partition in hive external table
I have a hive external table with 3 partition columns (A,B,C) and now I want to drop B and C columns from the partition.Is it possible to do so? 我有一个配置单元外部表,其中包含3个分区列(A,B,C),现在我想从分区中删除B和C列,是否可以这样做? I have tried with Alter table tab_name drop column col_name;
我已经尝试过使用Alter table tab_name删除列col_name; --- but it throws an error stating partitioned columns cannot be dropped.
---但是它抛出一个错误,指出不能删除分区的列。
To drop partition columns the table should be recreated . 要删除分区列, 应重新创建表。 The steps are:
这些步骤是:
MSCK repair table
. MSCK repair table
。 It will create partition metadata for all found partitions folders. If all of these steps seem too complex or too difficult to do, then simply create new table and load data : 如果所有这些步骤看起来太复杂或太难了,那么只需创建新表并加载数据:
Like this: 像这样:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table new_table partition(C)
select --list columns without deleted
from old_table;
And finally, after dropping old table, you can rename new one using ALTER TABLE table_name RENAME TO new_table_name
. 最后,删除旧表后,可以使用
ALTER TABLE table_name RENAME TO new_table_name
重命名新ALTER TABLE table_name RENAME TO new_table_name
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.