Q:

Merge multiple lines with non null values in Redshift

I would like to obtain one line only that contains the non null values from the table that can be reproduced from the following code:
select
  1 as unique_id,
  'null' as first,
  'second' as second,
  'null' as third
union all
select
  1 as unique_id,
  'first' as first,
  'null' as second,
  'null' as third
union all
select
  1 as unique_id,
  'null' as first,
  'null' as second,
  'third' as third

A:

The output of your supplied code (assuming 'null' should be NULL) is:
1, 'first', NULL, NULL
1, NULL, 'second', NULL
1, NULL, NULL, 'third'

By 'merge', I assume you want output that looks like:
1, 'first', 'second', 'third'

This could be done with:
SELECT MAX(first), MAX(second), MAX(third) FROM ... GROUP BY unique_id

Of course, this assumes you only have each value appearing once per unique_id.  You could similarly use other functions such as MIN or LISTAGG -- they simply have to be something that excludes NULL values.