The explode_split_outer table function is used to split a string into multiple substrings according to the specified delimiter, and expand each substring into 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_split_outer and explode_split is how they handle null values.
EXPLODE_SPLIT_OUTER(<str>, <delimiter>)
<str> String type, the string to be split.<delimiter> String type, the delimiter.<str> is NULL, 1 row with NULL is returned.<str> is an empty string ("") or cannot be split, 1 row is returned.<delimiter> is NULL, 1 row with NULL is returned.<delimiter> is an empty string (""), <str> will be split by bytes(SPLIT_BY_STRING).create table example( k1 int ) properties( "replication_num" = "1" ); insert into example values(1);
select * from example lateral view explode_split_outer("ab,cd,ef", ",") t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | ab | | 1 | cd | | 1 | ef | +------+------+
select * from example lateral view explode_split_outer("", ",") t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | | +------+------+
select * from example lateral view explode_split_outer("abc", ",") t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | abc | +------+------+
select * from example lateral view explode_split_outer(NULL, ',') t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | NULL | +------+------+
select * from example lateral view explode_split_outer('abc', '') t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | a | | 1 | b | | 1 | c | +------+------+
select * from example lateral view explode_split_outer('abc', null) t2 as c;
+------+------+ | k1 | c | +------+------+ | 1 | NULL | +------+------+