The explode_numbers_outer function accepts an integer and maps each number in the range to a separate row. It should be used together with LATERAL VIEW to flatten nested data structures into a standard flat table format. The main difference between explode_numbers_outer and explode_numbers is how they handle null values.
EXPLODE_NUMBERS_OUTER(<int>)
<int> Integer type[0, n), with column type Nullable<INT>.<int> is NULL, 0, or negative, 1 row with NULL is returned.select * from (select 1 as k1) t1 lateral view explode_numbers_outer(10) t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | 0 | | 1 | 1 | | 1 | 2 | | 1 | 3 | | 1 | 4 | | 1 | 5 | | 1 | 6 | | 1 | 7 | | 1 | 8 | | 1 | 9 | +------+------+
select * from (select 1 as k1) t1 lateral view explode_numbers_outer(0) t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | NULL | +------+------+
select * from (select 1 as k1) t1 lateral view explode_numbers_outer(NULL) t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | NULL | +------+------+
select * from (select 1 as k1) t1 lateral view explode_numbers_outer(-1) t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | NULL | +------+------+