Jie
Jie

Reputation: 65

Loading null values to Hive table

I have a .txt file that has the following rows:

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

when i created an external table, loaded the data and select *, i got null values. Please help how to show the number values instead of null. I very much appreciate the help!

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;

output:

Steve   [null]

Upvotes: 3

Views: 595

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44991

It seems the integers are separated by spaces and not tabs

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

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]

Upvotes: 1

Related Questions