I am trying to collect a column with NULL
s along with some values in that column...But collect_list
ignores the NULL
s and collects only the ones with values in it. Is there a way to retrieve the NULL
s along with other values ?
SELECT col1, col2, collect_list(col3) as col3
FROM (SELECT * FROM table_1 ORDER BY col1, col2, col3)
GROUP BY col1, col2;
Actual col3 values
0.9
NULL
NULL
0.7
0.6
Resulting col3 values
[0.9, 0.7, 0.6]
I was hoping that there is a hive solution that looks like this [0.9, NULL, NULL, 0.7, 0.6]
after applying the collect_list.
SELECT col1, col2, collect_list(coalesce(col3, "NULL") as col3 FROM (SELECT * FROM table_1 ORDER BY col1, col2, col3) GROUP BY col1, col2
– Pensile