Learn:Hive - Complex Data Type

I just want to initiate this topic on Hive Complex Data Types. Those who are interested can share your knowledge, use case, examples, questions, related to Complex data type

Hive supports 4 types of complex data types

ARRAY
MAP
STRUCT
UNIONTYPE

A sample table created with struct

create table customer
( cust_id int,
cust_address struct<aptno:string,
street:string,
city:string,
zip:string>
);

@saranvisa
In the case of complex data type the DDL script can be used as below:

create table family_details(
name string,
business_places array<string>,
sex_age struct <sex:string,age:int>,
fatherName_NoOfChildren Map<String,int>)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':';

Data can be visualized as below

Name | Location1,Location2…LocationN | Sex,age | FatherName:NoOfChildren

Arjun|delhi,bangalore,lahore|male,34|srivatsava:5

2 Likes

Thanks @Raja_Shyam

Can someone share Insert script on Complex Data Type!!

I got query to create table and query it but not to insert data

how would you do it for date type? lets say I have as_of_date column in hive table A datatype as string and in hive table B datatype as timestamp. When we insert the data from table A to table B, i’m getting null values. How do i resolve it?