The following bug has been logged on the website:
Bug reference: 16959
Logged by: Pete O'Such
Email address: posuch@gmail.com
PostgreSQL version: 11.7
Operating system: Ubuntu (and also Red Hat)
Description:
Applying unnest() to the output of string_to_array() operating on a null
silently drops the entire row from the query results. I'm agnostic
regarding what would be a proper resulting value within the column, but the
silent omission of the whole row from the result is a problem to me.
Sample data:
create table test_rows as
SELECT * FROM (VALUES (1, null), (2, 'second')) AS t (num,letter);
SELECT 2
Query with the unexpected result (I expected 2 rows):
select num, unnest(string_to_array(letter, ',')) from test_rows;
num | unnest
----+--------
2 | second
(1 row)
Correct or expected behavior from a similar operation:
select num, unnest(array[letter]) from test_rows;
num | unnest
----+--------
1 |
2 | second
(2 rows)
Thanks,
Pete O'Such