Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Loading CSV data into a Hive table

I have a CSV file which has rows in the following format,

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,

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,

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. What am I missing here?

The Hive version is Hive 1.2.1

like image 932
Leon Dmello Avatar asked May 25 '16 00:05

Leon Dmello


People also ask

Does Hive support CSV?

You can easily import tasks from a CSV file into a Hive project. To begin, download a sample CSV by going to your profile dropdown, then Import tasks, and selecting Import CSV. Then, fill out the following columns with your project details.


1 Answers

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 ',';
like image 104
Leon Dmello Avatar answered Sep 18 '22 20:09

Leon Dmello