Abh*_*ury 5 arrays dictionary hive
我正在尝试创建一个具有复杂数据类型的表。下面列出了数据类型。
大批
地图
数组<映射<字符串,字符串>>
我正在尝试创建 3 类型的数据结构。是否有可能在 Hive 中创建?我的表 DDL 如下所示。
create table complexTest(names array<String>,infoMap map<String,String>, deatils array<map<String,String>>)           
row format delimited                                                                                       
fields terminated by '/'                                                                                   
collection items terminated by '|'                                                                         
map keys terminated by '='                                                                                 
lines terminated by '\n';
我的示例数据如下所示。
Abhieet|Test|Complex/Name=abhi|age=31|Sex=male/Name=Test,age=30,Sex=male|Name=Complex,age=30,Sex=female
无论我从表中查询数据,我都会得到以下值
["Abhieet"," Test"," Complex"]  {"Name":"abhi","age":"31","Sex":"male"} [{"Name":null,"Test,age":null,"31,Sex":null,"male":null},{"Name":null,"Complex,age":null,"30,Sex":null,"female":null}]
这不是我所期待的。如果数据类型可能,请帮我找出应该是什么 DDLarray< map < String,String>>
我认为使用内置的 serde 这是不可能的。如果您提前知道映射中的值是什么,那么我认为解决此问题的更好方法是将输入数据转换为 JSON,然后使用Hive json serde:
样本数据:
{'Name': ['Abhieet', 'Test', 'Complex'],
'infoMap': {'Sex': 'male', 'Name': 'abhi', 'age': '31'},
 'details': [{'Sex': 'male', 'Name': 'Test', 'age': '30'}, {'Sex': 'female', 'Name': 'Complex', 'age': '30'}]
 }
表定义代码:
create table complexTest
(
names array<string>,
infomap struct<Name:string,
               age:string,
               Sex:string>,
details array<struct<Name:string,
               age:string,
               Sex:string>>
)
row format serde 'org.openx.data.jsonserde.JsonSerDe'
| 归档时间: | 
 | 
| 查看次数: | 31496 次 | 
| 最近记录: |