2

Referred this url : Hive - External table creation

Created Hive external table with location keyword and value is pointing to my local disk.

create external table exemp(id int,name string,age int) 
row format delimited 
fields terminated by ','
lines terminated by '\n'
stored as textfile
location 'file:///home/user/data';

But i am getting this error.

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:file:/home/user/data is not a directory or unable to create one)

But /home/user/data directory present in my local and have emp details. Any idea, why it is causing the issue

Vamsi Prabhala
  • 48,685
  • 4
  • 36
  • 58
Learn Hadoop
  • 2,760
  • 8
  • 28
  • 60

1 Answers1

2

The location which you are using here while creating hive table seems to be a local file location. We need to have HDFS path(or other compatible data source) in order to create a hive table. If you can just scp your data file to HDFS and then try with the HDFS location this will work.

Neha Kumari
  • 757
  • 7
  • 16
  • Kumar ,. So Location value always should point to HDFS directory. Not to our local file system. Is this correct? also read some article mentioned that we can provide our local file system or amzon s3.. bit confused. can you please provide more light on this – Learn Hadoop Feb 22 '18 at 05:32
  • Hey.. you can go through this link. – Neha Kumari Feb 22 '18 at 09:08
  • can you please post the link? – Learn Hadoop Feb 22 '18 at 09:09
  • hey, sorry... by mistake link didn't get post earlier. https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-ExternalTables – Neha Kumari Feb 22 '18 at 09:37
  • Also if you want to use the local file location to create the table you can use LOAD DATA INPATH '/user/data_path' INTO TABLE -- this syntax. For more details on this you can refer : https://cwiki.apache.org/confluence/display/Hive/Tutorial#Tutorial-LoadingData – Neha Kumari Feb 22 '18 at 09:39