0
votes

I am new to hadoop and in the learning phase. When I am trying to execute the below statement in hive, the empl.txt is being moved to trash folder.

load data inpath '/user/trnkimz/empl.txt' into table empl;

Also, the data is not getting stored in the empl table. In my empl table, I am having the below columns: e-id int and e_name String.

In my empl.txt file, I am having the below data in it:

1,john
2,smith
3,alex

Kindly suggest, that why I am not able to load data from HDFS to hive table. Thanks in advance.

2
- Check that /user/trnkimz/empl.txt is on HDFS, if it is on your local filesystem, use LOAD LOCAL DATA . - Also, make sure the table has the correct 'ROW FORMAT DELIMITED', check at: cwiki.apache.org/confluence/display/Hive/…Luís Bianchin

2 Answers

1
votes

First you have to check whether you are having your input file in local or hdfs .

If it is in local means you have to use LOAD DATA LOCAL INPATH '/home/username/inputfile' into table TABLENAME (this is equal to copyFromLocal)

If it is in HDFS means you have to use LOAD DATA INPATH '/inputfile' into table TABLENAME (this is equal to mv command in hdfs)

0
votes

we can load data to a hive table in 2 ways

1) load table with data with local data

hive> LOAD DATA LOCAL INPATH '' OVERWRITE INTO TABLE ;

2) load table with data with HDFS data

hive> LOAD DATA INPATH '' OVERWRITE INTO TABLE ;