- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Lateral View Outer Explode: Results in Rows Multipliers
- Labels:
-
Apache Hive
Created on ‎03-07-2019 01:18 PM - edited ‎09-16-2022 07:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am struggling with lateral view outer explode statement. This is the structure of my table:
TBL_CUSTOMER
CustId string
Cust_Resident_Country array
Item string
Cust_TaxIdenitity array
Item struct
Tin_issuing_country string
Tin string
CustId Cust_Resident_Country Cust_TaxIdenitity
1 [AU:HK] [{AU:987678;HK:76556}{ AU:987678;HK:76556}]
When I use the lateral view outer explode for this object I get 4 rows for the above row:
1 HK AU 987678
1 HK HK 765556
1 AU AU 987678
1 AU HK 76556
The desired result is :
1 HK AU 987678
1 AU HK 76556
And there are around 4 more array columns that have to be exploded.How do I stop the mapping of this UDTF mapping to each element of the array resulting in multiplication in row output.
Thanks!
Samir
Created ‎03-07-2019 02:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please share your query that has the LATERAL VIEW? This can help to see if you have any issues on your query.
Created ‎03-07-2019 02:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Thank you for your response.
I am running it for one account number
select distinct msg_bet_id
, atchd_doc_ref_id
, idv_cd as Resident_Country_Code
, idv_tin.tin as TIN
, idv_tin.tin_issg_cntry_cd as TIN_Country_Code
FROM tt17.crs_account_report a1
lateral view outer explode(hldr_idv_rsdnt_cntry_cds)exp1 as idv_cd
lateral view outer explode(hldr_idv_tins)exp2 as idv_tin
where accountnumber=123
