title: Using redshift system views with select pivot
body: <p>I'd like to pivot the values in the system views svv_*_privileges to show privileges assigned to security principles by object. (For the complete solution will need to union results for all objects and pivot to all privileges)</p>
  <p>as an example for the default privileges:</p>
  <pre><code>select * from
  (select object_type, grantee_name, grantee_type, privilege_type, 1 as is_priv from pg_catalog.svv_default_privileges where grantee_name = 'abc' and grantee_type = 'role')
  pivot (max(is_priv) for privilege_type in ('EXECUTE', 'INSERT', 'SELECT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'DROP') );
  </code></pre>
  <p>This gives error (only valid on leader node?)</p>
  <blockquote>
  <p>[Amazon](500310) Invalid operation: Query unsupported due to an internal error.</p>
  </blockquote>
  <p>Then thought of trying a temp table, pivot then being on a redshift table</p>
  <pre><code>select * into temp schema_default_priv from pg_catalog.svv_default_privileges where grantee_name = 'abc' and grantee_type = 'role'
  </code></pre>
  <p>... same error as above :-(</p>
  <p>Is there a way I can work with SQL on the system tables to accomplish this in Redshift SQL????</p>
  <p>While I can do the pivot in python ... why should I, It's supposedly a sql db!!!</p>