将空值加载到Hive表

时间:2017-03-26 20:47:45

标签: hive

我有一个.txt文件,其中包含以下行:

Steve,1 1 1 1 1 5 10 20 10 10 10 10

当我创建一个外部表,加载数据并选择*时,我得到了空值。请帮助如何显示数字值而不是null。我非常感谢你的帮助!

create external table Teller(Name string, Bill array<int>)
row format delimited
fields terminated by ','
collection items terminated by '\t'
stored as textfile
location '/user/training/hive/Teller';

load data local inpath'/home/training/hive/input/*.txt' overwrite into table Teller;

输出:

Steve   [null]

1 个答案:

答案 0 :(得分:1)

整数似乎用空格分隔而不是标签

的bash

hdfs dfs -mkdir -p /user/training/hive/Teller
echo Steve,1 1 1 1 1 5 10 20 10 10 10 10 | hdfs dfs -put - /user/training/hive/Teller/data.txt

蜂房

hive> create external table Teller(Name string, Bill array<int>)
    > row format delimited
    > fields terminated by ','
    > collection items terminated by ' '
    > stored as textfile
    > location '/user/training/hive/Teller';
OK
Time taken: 0.417 seconds
hive> select * from teller;
OK
Steve   [1,1,1,1,1,5,10,20,10,10,10,10]