title: Couldnt identify equality operator of type json[] when using UNION
body: <p>I'm trying to perform multiple queries on a single table using a <code>UNION</code> rule</p>
  
  <p>I have two tables:</p>
  
  <ul>
  <li>project (id, name, pinned BOOLEAN)</li>
  <li>skills (m2m to projects)</li>
  </ul>
  
  <p>I'm looking to first get an array of rows which have <code>pinned</code> set to <code>true</code> and fill up the remaining with the latest entries (<code>pinned</code> set to <code>false</code>)</p>
  
  <pre><code>SELECT
    project.id AS project_id,
    project.name AS project_name,
    array_agg(json_build_object('skill_id', project_skills.id,'name', project_skills.skill)) AS skills
  from project
  LEFT OUTER JOIN project_skills on project.name = project_skills.project
  WHERE project.pinned = true
  GROUP BY project_id,project_name
  
  UNION
  
  SELECT
    project.id AS project_id,
    project.name AS project_name,
    array_agg(json_build_object('skill_id', project_skills.id,'name', project_skills.skill)) AS skills
  from project
  LEFT OUTER JOIN project_skills on project.name = project_skills.project
  WHERE project.id != 1 AND project.pinned = false
  GROUP BY project_id,project_name
  ORDER BY project.create_date DESC LIMIT 5
  </code></pre>
  
  <p>When performing this query , i get the below error </p>
  
  <blockquote>
  <pre><code>ERROR:  could not identify an equality operator for type json[]
  LINE 7:   array_agg(json_build_object('skill_id', project_skills.id,...
  </code></pre>
  </blockquote>
  
  <p>I don't understand this error. Is it failing because its trying to compare the json columns from both results?</p>
  
  <p>I'm using Postgres 9.4.</p>