The explode_numbers 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 and explode_numbers_outer is how they handle null values.
EXPLODE_NUMBERS(<int>)
<int> Integer type[0, n), with column type INT.<int> is NULL or 0 or negative, 0 rows are returned.create table example( k1 int ) properties( "replication_num" = "1" ); insert into example values(1);
select * from example lateral view explode_numbers(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 example lateral view explode_numbers(0) t2 as c;
Empty set (0.03 sec)
select * from example lateral view explode_numbers(NULL) t2 as c;
Empty set (0.03 sec)
select * from example lateral view explode_numbers(-1) t2 as c;
Empty set (0.04 sec)