I have 2 tables in hive having Order's and Order_Detail's (having 1:n relation and joined on order_id) which I am trying to load to a single table taking advantage of hive complex data type - map[struct].
Say ORDER has below data,
Order_id total_amount customer
123 10.00 1
456 12.00 2
and ORDER_DETAILS have
Order_id Order_Item_id Item_amount Item_type
123 1 5.00 A
123 2 5.00 B
456 1 6.00 A
456 2 3.00 B
456 3 3.00 C
I would like to create single table ORDERS with all order columns and order_detail columns as map of structs. This helps me to combine related data and query together thus avoiding frequent joins. I tried loading table with complex data types using txt/json files input with respective serde's and it works well. But in this scenario I want to load data from existing 2 hive tables of ORCFile format into the new table. Have tried some basic insert using named_struct function but it loads each row separately and does not combine same order_id's into a single row.
Expected output something like ,
123 10.00 1 [1:{5.00,A},2:{5.00,B}]
456 12.00 2 {1:{6.00,A}, 2:{3.00,B},3:{3.00,C}]
but i get ,
123 10.00 1 [1:{5.00,A}]
123 10.00 1 [2:{5.00,B}]
456 12.00 2 {1:{6.00,A}]
456 12.00 2 {2:{3.00,B}]
456 12.00 2 {3:{3.00,C}]
Kindly help me understand the way of achieving this with just INSERT INTO table select from 2 tables. Thanks in advance.