#Declare the function once #standardSQL CREATE TEMP FUNCTION dedup(val ANY TYPE) AS (( SELECT ARRAY_AGG(t) FROM (SELECT DISTINCT * FROM UNNEST(val) v) t ));