Home > database >  HIVE how to migrate existing table HDFS path
HIVE how to migrate existing table HDFS path

Time:10-06

Background: because the system is a big data platform, there will be many different manufacturers in the HIVE zhongjian tables, so you need to have a standard to restrain manufacturer to store data,
For some manufacturers to store your data in the public directory, now need to migrate out of the specified directory, do not know to have what method;

The following is the specific problem description
1, manufacturer Y built A table A
Int the create table a (f1, f2, int... ) partition (xx, yy) location '/usr/hive/warehouse/a'.
To transfer data to A table '/usr/hive/warehouse/manufacturers' Y;
2, direct changes in the location (alter table a set location '/usr/hive factory/warehouse/Y/a') found the path of HDFS didn't change;

To online to check out some methods:
1, create a new table B, specify the location to the target path to create table B like a location '/usr/hive/warehouse/factory/B Y';
2, the migration of data to B,
The set hive. The exec. Dynamic. Partition=true;
The set hive. The exec. Dynamic. Partition. Mode=nonstrict;
For table or other tables A has A large number of partitions, so setting, can be automatically on maintenance partition table B
Insert the overwrite partition table B (xx, yy) select * from A;
3, the drop of the original table A drop table A;
4, renamed table for A, B alter table B rename to A;
Before step 4, B data storage directory or in the '/usr/hive/warehouse/factory/B Y', but after executed 4, exhibit A (the original table B) data storage directory and turned back to
'/usr/hive/warehouse/a, the results failed;

Do you have what good method, thank you!

CodePudding user response:

What is ah, have Daniel to help overcome?

CodePudding user response:

Met the same problem, finally how to solve, you have what better way

CodePudding user response:

With the solution
  • Related