title: How to get distinct array elements with postgres?
body: <p>I have an array with duplicate values in postgres. For example:</p>
  
  <pre><code>SELECT cardinality(string_to_array('1,2,3,4,4', ',')::int[]) as foo
  =&gt; "foo"=&gt;"5"
  </code></pre>
  
  <p>I would like to get unique elements, for example:</p>
  
  <pre><code>SELECT cardinality(uniq(string_to_array('1,2,3,4,4', ',')::int[])) as foo
  =&gt; -- No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  
  <p>Can I get unique elements of an array in postgres without using UNNEST ?</p>