My table is like this in Hive:-
col1 | col2 | col3
C1 | F1,F2,F3 | V1,V2,V3
I need output in below format:-
col1 | col2 | col3
C1 | F1 | V1
C1 | F2 | V2
C1 | F3 | V3
I used the explode function as below:-
select col1, exp_col2, exp_col3
from my_table
LATERAL VIEW EXPLODE (split(col2, ',')) col2table AS exp_col2
LATERAL VIEW EXPLODE (split(col3, ',')) col3table AS exp_col3;
This query is doing cross join on col1, instead of returning 3 rows it is returning 9 rows as output.
Can anyone please help me out here?