0
votes

i have created table in hive. not external, keeping table structure same of the file which is located in HDFS.

When i loaded data from HDFS to table in hive metastore, its successfully loaded but only with NULLs and not the actual data. i understand Schema on Read concept, but how can i assure whatever data present in file load to table successfully.

may someone please suggest how to resolve such issue.

Thanks

2
Please mention the query you used to ingest data in the hive(Create table Query). Then only i'll be able to help you - Abhinav
Show your file and the table create query - OneCricketeer

2 Answers

1
votes

Please check if you are using correct syntax to create your tables with the correct data types.

CREATE TABLE IF NOT EXISTS employee ( eid int, name String,salary String, 
destination String)
COMMENT ‘Employee details’
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
LINES TERMINATED BY ‘\n’

you should check if the 'fields terminated by' and 'lines terminated by' correct. Number of columns in your file and table should match.

If you still face the issue, please provide your create table statement and insert statements and sample data from your file.

Thanks

0
votes

Becareful of empty space. Sometimes you need to check whether the raw data have empty space or not, this will become problem if you define the datatype other than String (the conversion will be failed which return null values). One example is when you define you column datatype as double but the data you load contained space (For example: '0.5 ') it will produce null value. If this is the problem you can create new table with all columns in String datatype then trim and cast it to other data type.