【发布时间】:2015-08-05 16:03:15
【问题描述】:
我有一个文件。它包含 4 个字段,其中最后两个字段是数组。所以我在 Hive 中创建了表:
create table testtable(f1 string, f2 string, f3 array<string>) row format delimited fields terminated by ',' collection items terminated by ',';
数据:
a,b,c,d
1,sdf,2323,sdaf
1,sdf,34,wer
1,sdf,223,daf
1,sdf,233,af
当我使用以下查询将数据加载到表中时,它会成功加载数据,但结果不正确。它没有加载数组中的最后两个字段,只加载了一个字段。结果如下:
load data inpath 'data/file.txt' into table testtable;
结果:
hive> select * from testtable;
OK
a b ["c"]
1 sdf ["2323"]
1 sdf ["34"]
1 sdf ["223"]
1 sdf ["233"]
所以问题是如何加载具有相同集合分隔符的数组字段中的数据?我的源文件将始终包含相同的分隔符。
【问题讨论】: