问题
Let's suppose I have two hive tables, table_1
and table_2
. I use:
ALTER TABLE table_2 ADD PARTITION (col=val) LOCATION [table_1_location]
Now, table_2
will have the data in table_1
at the partition where col = val
.
What I want to do is reverse this process. I want table_2
not to have the partition at col=val
, and I want table_1 to keep its original data.
How can I do this?
回答1:
Make your table EXTERNAL first:
ALTER TABLE table_2 SET TBLPROPERTIES('EXTERNAL'='TRUE');
Then drop partition, the data will remain, only table_2 partition metadata will be deleted:
ALTER TABLE table_2 DROP PARTITION (col=val)
table_1 partition data will remain as is.
来源:https://stackoverflow.com/questions/56747307/how-to-undo-alter-table-add-partition-without-deleting-data