Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to change location of the external table in hive .

avatar
Expert Contributor

1) CREATE EXTERNAL TABLE IF NOT EXISTS jsont1( json string ) LOCATION '/jsam';

Now I need to change the location from where above json1 points to.

I tried this command - ALTER TABLE jsont1 SET LOCATION "/jsam/j2" ;

but getting error as below :

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. {0} is not absolute or has no scheme information. Please specify a complete absolute uri with scheme information. /jsam/j2

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Its now running using below , thanks for all your help :

hive> ALTER TABLE jsont1 SET LOCATION "hdfs:/jsam/j1";

OK Time taken: 0.245 seconds

hdfs:/ : Did you know then why its not running using hdfs:// (double slash)

View solution in original post

7 REPLIES 7

avatar
Super Guru

can you try this one

alter table jsont1 set location "hdfs://jsam/j2"

avatar
Expert Contributor

@Rajkumar Singh

Yes I tried this also .. getting as below

FAILED: IllegalArgumentException java.net.UnknownHostException: jsam

Below text to show jsam is available in hdfs :

hive> dfs -ls /jsam;

Found 1 items drwxr-xr-x - hadoop supergroup 0 2016-05-06 12:49 /jsam/j1

avatar
Super Guru

can you post the full dfs location from the output of the below command

describe formatted jsont1;

avatar
Expert Contributor

@Rajkumar Singh

hive> describe formatted jsont1; OK col_name data_type comment # col_name data_type comment json string # Detailed Table Information Database: logs Owner: hadoop CreateTime: Tue May 03 15:24:27 IST 2016 LastAccessTime: UNKNOWN Protect Mode: None Retention: 0 Location: hdfs://mycluster:8020/jsam Table Type: EXTERNAL_TABLE Table Parameters: COLUMN_STATS_ACCURATE false EXTERNAL TRUE numFiles 0 numRows -1 rawDataSize -1 totalSize 0 transient_lastDdlTime 1462269267 # Storage Information SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe InputFormat: org.apache.hadoop.mapred.TextInputFormat OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat Compressed: No Num Buckets: -1 Bucket Columns: [] Sort Columns: [] Storage Desc Params: serialization.format 1

avatar
Super Guru

@Amit Dass

can you try this

ALTER TABLE jsont1 SET LOCATION "hdfs://mycluster:8020/jsam/j1";

avatar
Expert Contributor

Its now running using below , thanks for all your help :

hive> ALTER TABLE jsont1 SET LOCATION "hdfs:/jsam/j1";

OK Time taken: 0.245 seconds

hdfs:/ : Did you know then why its not running using hdfs:// (double slash)

avatar
Visitor

The full format of an HDFS uri is:

 

 

 

hdfs://NAMESERVICE/path/to/your/file
hdfs://NAMESERVICE/path/to/your/directory

 

 

 

or

 

 

 

hdfs://ANYNAMENODE:PORT/path/to/your/file
hdfs://ANYNAMENODE:PORT/path/to/your/directory

 

 

 

 

It is ok to omit the nameservice/namenode part (to use the defaultFs).

To do it correctly, you need to keep the `hdfs://` part and relative path that starts with a `/`.

That is:

 

 

 

hdfs:///path/to/your/file

 

 

 

(Note that it looks like `hdfs:` followed by 3x `/`s)