Amazon Redshift "cache lookup failed for aggregate" error when using median aggregate
Amazon recently added support for the 'median' window function. If you forget that it's only a window function and try to use it like an aggregate, you'll get this error:

dev=# select median(5);
ERROR:  cache lookup failed for aggregate 2762


The solution is to rephrase the query to use it as a window function:

dev=# select median(5) over ();
 median 
--------
   5


(1 row)