Ina
Ina

Reputation: 11

Why HIVE table is returning Null Values

I have coded this to Create an External Table:

CREATE EXTERNAL TABLE IF NOT EXISTS carss (
> maker STRING,
> model STRING,
> mileage FLOAT,
> manufacture_year INT, 
> engine_displacement FLOAT,
> engine_power STRING,
> body_type STRING,
> color_slug STRING,
> stk_year FLOAT,
> transmission STRING,
> door_count INT,
> seat_count INT,
> fuel_type STRING, 
> date_created DATE, 
> date_last_seen DATE,
> price_eur FLOAT)
> ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
> LOCATION '/BigData/Project2/'
> TBLPROPERTIES ("skip.header.line.count"="1", 'creator'='Janina', 'created_on'='2020-11-05', 'description'='dataset for classified Ads of cars in Germany and Czech Republic');

And when I run the query SELECT * FROM carss LIMIT 1; it returns null values and weird characters

hive> SELECT * FROM carss LIMIT 1;

OK ��T�;��9fu7z�C�WHqd��Y�P�c��/�^�B�4���*G����Ç�ǿN������y�z~>����Ǘ�?�Oo��ӿ��������r�������������ݷ����|������N����r����������o����������2}�����x=�ʗ����/�||;������9������߯�����z~:���~��\���/��㏟�vZ)5�5��_i�4��� �erS�>�O��D��I�O����տ�?D���?�o��d��1�_V�K�����?�h����׿.��������|��<��ң^ w��X���c�������Ӕ���S���F$z��J�FywP�.����X�S��T��CM6lE9�^��j� h� NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Time taken: 0.059 seconds, Fetched: 1 row(s) hive>

Upvotes: 1

Views: 677

Answers (1)

Dagang Wei
Dagang Wei

Reputation: 26458

Is your file in /BigData/Project2/ encoded in utf-8? If not, you might need to specify the encoding of the underlying file when creating the external table:

  create external table carss 
     ...
  row format
      serde 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
      with serdeproperties("serialization.encoding"='WINDOWS-1252') 
  location
      ...

This article might be helpful.

Upvotes: 0

Related Questions