首页 > 解决方案 > 为什么 HIVE 表返回空值

问题描述

我已经对此进行了编码以创建一个外部表:

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');

当我运行查询 SELECT * FROM carss LIMIT 1; 它返回空值和奇怪的字符

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 所用时间:0.059 秒,获取:1 行 hive>

标签: hive

解决方案


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.


推荐阅读