Mudi
Mudi

Reputation: 95

How I avoid the "NULL" in the first "Field Name" of Hive table

First of all I have created the table "emp" in Hive by using below commands:

create table emp (id INT, name STRING, address STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t';

Then load the data in this "emp" table by this below command: LOAD DATA LOCAL INPATH '\home\cloudera\Desktop\emp.txt' overwrite into table emp;

When I select the data from "emp" table: it show me first field of table Null like this:

enter image description here

Upvotes: 0

Views: 1332

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44941

You have an header row in your file and the first value id cannot be converted into INT therefore being replaced by NULL.

add tblproperties ("skip.header.line.count"="1") to your table definition

For an existing table -

alter table emp set tblproperties ("skip.header.line.count"="1");

Upvotes: 3

Related Questions