gpt4 book ai didi

hive - 将空值加载到 Hive 表

转载 作者:行者123 更新时间:2023-12-05 01:08:12 26 4
gpt4 key购买 nike

我有一个包含以下行的 .txt 文件:

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

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

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]

最佳答案

似乎整数是用空格而不是制表符分隔的

庆典

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]

关于hive - 将空值加载到 Hive 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43034370/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com