Hive alter location statement not working

2019-02-17 16:51发布

问题:

hive> alter table my_table_name set location "hdfs://nameservice1/foo";
OK
Time taken: 0.173 seconds
hive> alter table my_table_name set location "hdfs://nameservice1/foo/bar";
Authorization failed:org.apache.hadoop.security.AccessControlException: action WRITE not permitted on path hdfs://nameservice1/foo for user hadoop_user. Use show grant to get more details.

As seen in the above screen output, the alter table location is working exactly once on the external table and subsequently it is throwing an error. Please advice how I could get the alter table location statement to work.

回答1:

I figured out the error and fixed it. The issue was that during the creation of the table i set its location to a non existent path on hdfs. So when i was trying to alter its location,it wasn't allowing me to do so.

The resolution: I first created the directory to which the table was currently pointed to and then created the directory to which i wanted to point the table to. Then the alter table location statement worked as required.



回答2:

I think the best is to use a script to check that using

hdfs fs -ls ///

and then to call beeline with an external script



回答3:

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...



标签: hive