简体   繁体   English

无法将数据从HDFS加载到Hadoop中的Hive

[英]Not able to load data from HDFS to Hive in Hadoop

I am new to hadoop and in the learning phase. 我是hadoop的新手,正在学习阶段。 When I am trying to execute the below statement in hive, the empl.txt is being moved to trash folder. 当我尝试在蜂巢中执行以下语句时, empl.txt被移至垃圾箱文件夹。

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

Also, the data is not getting stored in the empl table. 同样,数据也不会存储在empl表中。 In my empl table, I am having the below columns: e-id int and e_name String . 在我的empl表中,我有以下e_name String列: e-id inte_name String

In my empl.txt file, I am having the below data in it: 在我的empl.txt文件中,其中包含以下数据:

1,john
2,smith
3,alex

Kindly suggest, that why I am not able to load data from HDFS to hive table. 请建议,为什么我不能将数据从HDFS加载到配置单元表。 Thanks in advance. 提前致谢。

First you have to check whether you are having your input file in local or hdfs . 首先,您必须检查您的输入文件是否在local或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) 如果在本地,则必须在表TA​​BLENAME中使用LOAD DATA LOCAL INPATH'/ home / username / inputfile'(等于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) 如果它在HDFS中,则意味着您必须在表TA​​BLENAME中使用LOAD DATA INPATH'/ inputfile'(这等同于hdfs中的mv命令)

we can load data to a hive table in 2 ways 我们可以通过两种方式将数据加载到配置单元表

1) load table with data with local data 1)用本地数据加载表

hive> LOAD DATA LOCAL INPATH '' OVERWRITE INTO TABLE ; 蜂巢>加载数据本地入口''覆盖到表;

2) load table with data with HDFS data 2)用HDFS数据加载表数据

hive> LOAD DATA INPATH '' OVERWRITE INTO TABLE ; 蜂巢>加载数据路径''覆盖到表;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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