How to explode two column in hive

 How to explode two column in hive

Consider table (dxc) as


#create table dxc

CREATE TABLE dxc (CustomerID int, Account ARRAY<STRING>, Account_type ARRAY<STRING>);

#insert data into table dxc

INSERT INTO TABLE dxc SELECT 111,ARRAY("111-1234", "111-9876"),ARRAY("SAVINGS", "CURRENT") UNION ALL SELECT 222,ARRAY("222-5678", "222-5432"),ARRAY("CURRENT", "SAVINGS");

#explode the data

SELECT CustomerID,exploded_account,exploded_account_type FROM dxc LATERAL VIEW posexplode(Account) exploded_accounts AS pos, exploded_account LATERAL VIEW posexplode(Account_type) exploded_account_types AS pos2, exploded_account_type WHERE pos = pos2;





Comments