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? I have tried with Alter table tab_name drop column 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
. 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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.