I want to select distinct values of columns for each user in my table (in Google BigQuery). I've thought about using ARRAY_AGG() like:
SELECT user_id, ARRAY_AGG(DISTINCT field1) AS f1, ARRAY_AGG(DISTINCT field2) AS f2
FROM t GROUP BY user_id
But because for some user_ids all values in field1 or field2 are null, I get this error message: Array 'f1' cannot have a null element
I wonder if there is a workaround to avoid this error or maybe a different way to achieve the result without using ARRAY_AGG()
ARRAY_AGGas well). I made some progress on the feature but don't have anything to announce yet.