Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HIVE LOAD DATA INPATH

Tags:

hadoop

hive

I tried to create a table in hive using the following command:

CREATE TABLE apple (dates STRING, open INT, high INT, low INT, close INT, adj_close DECIMAL, vol INT) row format delimited fields terminated by ',' lines terminated by '\n' tblproperties ("skip.header.line.count"="1");**

Then I tried to load data using the command:

LOAD DATA INPATH '/user/root/stockdata/APPL.csv' OVERWRITE INTO TABLE apple;

The file APPL.csv is stored in HDFS

Executing the above resulted in the following error:

Error: Error while compiling statement: FAILED: SemanticException Unable to load data to destination table. Error: The file that you are trying to load does not match the file format of the destination table. (state=42000,code=40000)

Can someone help resolve this?

like image 438
Sreelekshmy Selvin Avatar asked Oct 28 '25 11:10

Sreelekshmy Selvin


1 Answers

Put the file directly into table location.

hdfs dfs -copyFromLocal /user/root/stockdata/APPL.csv' /user/<username>/apple 

Substitute destination location with your table location. You can check it using DESCRIBE FORMATTED tablename.

like image 181
leftjoin Avatar answered Oct 31 '25 09:10

leftjoin