首页 > 解决方案 > 从 CSV 文件加载数据时配置单元中 INT 列的空值

问题描述

当我将 csv 文件中的数据加载到 hive 表中时,除字符串头之外的所有 int 头都显示为空。

我有 pokemon.csv 文件,其列标题如下

#   Name    Type 1  Type 2  Total   HP  Attack  Defense Sp. Atk Sp. Def Speed
1   Bulbasaur   Grass   Poison  318 45  49  49  65  65  45
2   Ivysaur Grass   Poison  405 60  62  63  80  80  60
3   Venusaur    Grass   Poison  525 80  82  83  100 100 80

我有如下表

CREATE TABLE pokemon (
Number Int,
Name String,
Type1 String,
Type2 String,
Total Int,
HP Int,
Attack Int,
Defense Int,
Sp_Atk Int,
Sp_Def Int,
Speed Int
) 
row format delimited 
fields terminated BY ',' 
lines terminated BY '\n' 
tblproperties("skip.header.line.count"="1");

我得到如下结果

hive> select * from pokemon limit 2;         
OK
NULL    Name    Type 1  Type 2  NULL    NULL    NULL    NULL    NULL    NULL    NULL
1   Bulbasaur   Grass   Poison  318 45  49  49  65  65  45
Time taken: 0.163 seconds

不知道为什么我只为 INT 列获取 NULL 标题。请问有人可以帮忙吗?

标签: csvhive

解决方案


推荐阅读