在您的配置单元表中,位于 address 映射内的结构中字段之间的分隔符为\ u004(Unicode 4),并且不能被覆盖.您应该将输入更改为: 1000,Suresh--S,1234567890-1234567890,home = Venkatapuram1 \ u00042020 \ u00045000011001,Mahesh-X-M,1234567890-1234567890,home = Venkatapuram2 \ u00042021 \ u0004500001 Hive Version 2.1.1Problem Description: collection items terminated values are inserted as Map KeysHive Table:CREATE TABLE profiles(id int,name struct<first_name: string, middle_name: string, last_name: string>,phone struct<home: string, office: string>,address map<string,struct<streat:string, appartment:int, zip:string>>) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','COLLECTION ITEMS TERMINATED BY '-'MAP KEYS TERMINATED BY '='LINES TERMINATED BY '\n'STORED AS TEXTFILE;Data:1000,Suresh--S,1234567890-1234567890,home=Venkatapuram1-2020-5000011001,Mahesh-X-M,1234567890-1234567890,home=Venkatapuram2-2021-500001Data Load:load data inpath '/handson/profiles_data.txt' overwrite into table profiles;Actual data from select statement:SELECT * FROM profiles; 1000 {"first_name":"Suresh","middle_name":"","last_name":"S"} {"home":"1234567890","office":"1234567890"} {"home": {"streat":"Venkatapuram1",**"appartment":null,"zip":null},"2020":null, "500001": null}1001 {"first_name":"Mahesh","middle_name":"X","last_name":"M"} {"home":"1234567890","office":"1234567890"}{"home": {"streat":"Venkatapuram2",**"appartment":null,"zip":null},"2021":null, "500001": null}Expected: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"**}} 解决方案 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 address map is \u004 (Unicode 4), and it can't be overridden. You should change your input to:1000,Suresh--S,1234567890-1234567890,home=Venkatapuram1\u00042020\u0004500001 1001,Mahesh-X-M,1234567890-1234567890,home=Venkatapuram2\u00042021\u0004500001 这篇关于Apache Hive-复杂数据类型映射< string,struct>不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 07:39