简体   繁体   中英

Loading data in Hive table with Hadoop

I'm looking to load data in Hive table by a .sql script but I get an issue like this :

hduser@master:~$ hive -f script.sql 

Logging initialized using configuration in jar:file:/home/hduser/ecosystem/apache-hive-2.3.0-bin/lib/hive-common-2.3.0.jar!/hive-log4j2.properties Async: true
OK
Time taken: 5.798 seconds
Loading data to table default.test
Failed with exception Unable to move source file:/home/hduser/Data.txt to destination hdfs://master:9000/user/hive/warehouse/test/Data.txt
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to move source file:/home/hduser/Data.txt to destination hdfs://master:9000/user/hive/warehouse/test/Data.txt

My script looks like :

CREATE TABLE IF NOT EXISTS Test (
id int, mdp string, id_employe int, category int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n' ;

LOAD DATA LOCAL INPATH '/home/hduser/Data.txt' OVERWRITE INTO TABLE Test ;

Permissions in /home/hduser are :

hduser@master:~$ ls -l
total 5364168
-rwx-wx-wx 1 hduser hduser 5492885458 août  24 11:38 Data.txt
-rw-rw-r-- 1 hduser hduser        684 août  24 12:14 derby.log
drwxrwxr-x 3 hduser hduser       4096 juil. 26 11:46 ecosystem
drwxrwxr-x 5 hduser hduser       4096 août  24 12:14 metastore_db
-rwx-wx-wx 1 hduser hduser        233 août  24 12:10 script.sql

Data looks like :

1, jhkjhkjh, 18, 11
2, poilll, 87, 13
3, aoudliaoiud, 98, 76
...

In http://172.30.10.182:50070/explorer.html#/ I have :

drwx-wx-wx  hduser  supergroup  0 B Aug 24 11:40    0   0 B tmp
then
drwx-wx-wx  hduser  supergroup  0 B Aug 24 11:40    0   0 B hive
then 
drwx-wx-wx  hduser  supergroup  0 B Aug 24 12:14    0   0 B hduser
then 
drwx-wx-wx  hduser  hduser  0 B Aug 24 12:12    0   0 B warehouse
then 
drwx-wx-wx  hduser  hduser  0 B Aug 24 12:12    0   0 B test

Do you have any idea why I can fill my test table with data from Data.txt ?

The directory that you are tying to write the file to is

/user/hive/warehouse/test/

The rights that you check via the explorer are for

/tmp/hive/warehouse/test/

So here is a clear mismatch.

I think you have permission issue in haddop. provide permission using below one command and also verify that data.txt file is not corrupt

hadoop fs -chmod g+w /user/hive/warehouse/test/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM