Please refer to the below example that would guide in working with Map, Collections in Hive.

Input data:

Naveen 99999.9 <"Eben","Ryan"> <"Health" 5000,"Travel" 10000> <street:"20-102",city:"Hyd",state:"TS",zip:501219>
Praveen 99999.9 <"Eben","Ryan"> <"Health" 5000,"Travel" 10000> <street:"20-102",city:"Hyd",state:"TS",zip:501219>
Vignan 99999.9 <"Eben","Ryan"> <"Health" 5000,"Travel" 10000> <street:"20-102",city:"Hyd",state:"TS",zip:501219>

Note: The fields in the input file are separated by tab.

create table employees(
name STRING,
salary FLOAT,
subordinates ARRAY<STRING>,
deductions MAP<STRING, FLOAT>,
address STRUCT<street:STRING, city:STRING, state:STRING, zip:STRING>
)
row format delimited
fields terminated by '\t'
collection items terminated by ','
map keys terminated by ' '
lines terminated by '\n'
stored as textfile;

load data local inpath '/home/edureka/emp' into table employees;

select * from employees;

Please refer to the below screenshot.



Hope this helps.

220053