简体   繁体   English

将CSV数据加载到Hive表时出错

[英]Error Loading CSV data into a Hive table

I have a CSV file which has rows in the following format, 我有一个CSV文件,其中包含以下格式的行,

1, 11812, 15273, "2016-05-22T111647.800 US/Eastern", 82971850, 0
1, 11812, 7445, "2016-05-22T113640.200 US/Eastern", 82971928, 0
1, 11654, 322, "2016-05-22T113845.773 US/Eastern", 82971934, 0
1, 11722, 0, "2016-05-22T113929.541 US/Eastern", 82971940, 0

The I create a Hive table with the following command, 我使用以下命令创建一个Hive表,

create table event_history(status tinyint, condition smallint,
machine_id int, time timestamp, ident int, state tinyint)

Then I am trying to load the CSV file into the table with the following command, 然后我尝试使用以下命令将CSV文件加载到表中,

load data local inpath "/home/ubuntu/events.csv" into table event_history;

But all I get is NULLs when I try to do a select query in the created table. 但是当我尝试在创建的表中执行select查询时,我得到的只是NULL。 What am I missing here? 我在这里错过了什么?

The Hive version is Hive 1.2.1 Hive版本是Hive 1.2.1

My error was in the table creation. 我的错误是在表创建中。 Fixed it with the following changes 通过以下更改修复了它

create table event_history(status tinyint, condition smallint, machine_id int,
time timestamp, drqs int, state tinyint) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

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

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