Support Questions

Find answers, ask questions, and share your expertise

how to change hive external table location.

avatar
Contributor

I want to change my external table hdfs location to new path location which is Amazon S3 in my case.

I tried following query.

ALTER TABLE table_name set location 's3n://bucket/path/to/data'

But some how it is still pointing to old hdfs external path.

Is there any query I need to use in order to update hive metastore with new external data path location.

Any kind of help would be greatly appreciated .

9 REPLIES 9

avatar
Super Collaborator

@Girish Chaudhari

what happened right after you executed the Alter table command? Did you get any errors?

I am assuming, you tried describe extended <table_name> to determine the location that it is referring to??

avatar
Contributor

@hduraiswamy I am able to execute alter query, I didn't get any errors . Yes i have tried extended describe command as well to get location info.

avatar
Master Guru

DROP the current table (files on HDFS are not affected for external tables), and create a new one with the same name pointing to your S3 location.

avatar
Contributor

@Predrag Minovic I also tried this work around it is working partially for me as i have to recover all the table partition because somehow it doesn't detect s3 sub directories .

avatar
Rising Star

Check if you have provided the aws access keys correctly and if there are any exceptions reported in hive client log (e.g /tmp/<user>/hive.log).

avatar
Contributor

@Rajesh Balamohan I have aws access id & secret stored in in hive-site and hdfs-site config file.

avatar
Rising Star

are there any exceptions reported in client log or in metastore log?

avatar

on hive terminal run below command

alter table FpML_Data set location hdfs:/file_path_in_HDFS;

HDFS: is value against fs.defaultFS property in core-site.xml

Reply my comment if in case any query...

avatar
Expert Contributor

@Girish Chaudhari

Note, when you change the location of the file by using alter command, the old data file is not moved to new location.

On your issue, 1) do you have any data files in the mentioned path?

2) Did you get any warnings / errors while you executed this ALTER command?