0
votes

I have used lateral view explode multiple times (around 9 times) in a single query on the single table(size around 12GB). This generated a huge amount of map side data (100Pb+). I couldn't understand how it generated this amount of data from 12GB.

Can someone please explain how lateral explode works (internally)?

Thanks in advance

1

1 Answers

2
votes

Demo

create table mytable (a1 array<int>,a2 array<int>,a3 array<int>);
insert into mytable select array(1,2),array(3,4,5),array(6,7,8,9);

select  *

from    mytable
        lateral view explode (a1) e1 as a1_val
        lateral view explode (a2) e2 as a2_val
        lateral view explode (a3) e3 as a3_val
;        

+-------+---------+-----------+--------+--------+--------+
|  a1   |   a2    |    a3     | a1_val | a2_val | a3_val |
+-------+---------+-----------+--------+--------+--------+
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      3 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      3 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      3 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      3 |      9 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      4 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      4 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      4 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      4 |      9 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      5 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      5 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      5 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      1 |      5 |      9 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      3 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      3 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      3 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      3 |      9 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      4 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      4 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      4 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      4 |      9 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      5 |      6 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      5 |      7 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      5 |      8 |
| [1,2] | [3,4,5] | [6,7,8,9] |      2 |      5 |      9 |
+-------+---------+-----------+--------+--------+--------+