I'm not able to run this unless I'm the Postgres super user. But if I run it as such, it tells me that cast already exists anyway.
CREATE CAST (text AS varchar) WITH INOUT AS IMPLICIT;
ERROR: cast from type text to type character varying already exists
Of course this will work fine:
INSERT INTO foo (my_array) SELECT DISTINCT '{TEST}'::varchar[];
I was mostly surprised by having DISTINCT added to a SELECT make things break. It may be too obscure an issue to be worth adding, but nothing on the DISTINCT documentation suggests this possibility.
"If DISTINCT is specified, all duplicate rows are removed from the result set..."
Cheers,
Ken