Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive table is loading with NULL values

Solved Go to solution
Highlighted

Hive table is loading with NULL values

New Contributor

CREATE TABLE IF NOT EXISTS employee (eid int, name String,
salary String)
STORED AS TEXTFILE;

LOAD DATA LOCAL INPATH '/user/hdadmin/sample.txt' OVERWRITE INTO TABLE employee;

Sample.txt

1201^AGopal^A45000
1202^AManisha^A45000
1203^AMasthanvali^A40000
1204^AKiran^A40000
1205^AKranthi^A30000

Both queries were executed successfully, but the table have only NULL values,

Output:

hive> select * from employee;
OK
NULL NULL NULL
NULL NULL NULL
NULL NULL NULL
NULL NULL NULL
NULL NULL NULL
Time taken: 0.148 seconds, Fetched: 5 row(s)

Please help me to fix this

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Hive table is loading with NULL values

New Contributor

Thank you @Jonathan Sneep I resolved the issue. It is due to typing the query in text editor and copied it to hive cli, the single quote was malformed.

2 REPLIES 2

Re: Hive table is loading with NULL values

Hi @Sivakumar Mahalingam

Try creating your table like this instead;

CREATE TABLE IF NOT EXISTS employee2 (eid int, name String,salary String)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' WITH SERDEPROPERTIES ("field.delim"="^A","line.delim" = '\n')
STORED AS TEXTFILE;

PS. If this helps to resolve your issue, please take a moment to click accept answer :)

Re: Hive table is loading with NULL values

New Contributor

Thank you @Jonathan Sneep I resolved the issue. It is due to typing the query in text editor and copied it to hive cli, the single quote was malformed.