Apache Hive-复杂数据类型映射< string,struct>不工作 [英] Apache Hive - Complex DataType Map<string, struct> not working
问题描述
配置单元版本 2.1.1
问题描述:收集项的终止值作为映射键插入
配置单元表:
CREATE TABLE配置文件(id int,名称struct< first_name:字符串,middle_name:字符串,last_name:字符串> ;,电话struct<家庭:字符串,办公室:字符串> ;,地址映射< string,struct< streat:string,appartment:int,zip:string>>)行格式已定界以','结尾的字段收集项目以-"结尾映射键以'='终止'\ n'终止的行存储为文本文件;
数据:
1000,Suresh--S,1234567890-1234567890,home = Venkatapuram1-2020-5000011001,Mahesh-X-M,1234567890-1234567890,home = Venkatapuram2-2021-500001
数据加载:
load inpath数据'/handson/profiles_data.txt'覆盖到表概要文件中;
select语句中的实际数据:
SELECT * FROM配置文件;1000{"first_name":"Suresh","middle_name":","last_name":"S"}{"home":"1234567890","office":"1234567890"}{家":{"streat":"Venkatapuram1",**"appartment":null,"zip":null},"2020":null,"500001":null}1001{"first_name":"Mahesh","middle_name":"X","last_name":"M"}{"home":"1234567890","office":"1234567890"}{家":{"streat":"Venkatapuram2",**"appartment":null,"zip":null},"2021":null,"500001":null}
预期:
1000{"first_name":"Suresh","middle_name":","last_name":"S"}{"home":"1234567890","office":"1234567890"}{"home":{"streat":"Venkatapuram1",**"appartment":2020,"zip":"500001"} **}1001{"first_name":"Mahesh","middle_name":"X","last_name":"M"}{"home":"1234567890","office":"1234567890"}{"home":{"streat":"Venkatapuram2",**"appartment":2021,"zip":"500001" **}}
答案如下: Expected:
As answered in: HIVE nested ARRAY in MAP data type, you can only override the first three delimiters in hive, while hive actually supports 8. In nested data structures, for each nesting level, a consequent delimiter is used. In your hive table, the delimiter between fields in the struct that is inside the You should change your input to:
这篇关于Apache Hive-复杂数据类型映射< string,struct>不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!1000
{"first_name":"Suresh","middle_name":"","last_name":"S"}
{"home":"1234567890","office":"1234567890"}
{"home":{"streat":"Venkatapuram1",**"appartment":2020,"zip":"500001"}**}
1001
{"first_name":"Mahesh","middle_name":"X","last_name":"M"}
{"home":"1234567890","office":"1234567890"}
{"home": {"streat":"Venkatapuram2",**"appartment":2021,"zip":"500001"**}}
address
map is \u004 (Unicode 4), and it can't be overridden. 1000,Suresh--S,1234567890-1234567890,home=Venkatapuram1\u00042020\u0004500001
1001,Mahesh-X-M,1234567890-1234567890,home=Venkatapuram2\u00042021\u0004500001