Optimize aggregations over partition keys into simple metadata queries

This optimization rewrites aggregations that are insensitive to the
cardinality of their input (i.e., min, max, distinct aggregates) as
partition metadata queries when the input columns are only partition keys

These are a few examples of queries that benefit:

```sql
SELECT min(key), max(key) FROM t

SELECT DISTINCT key FROM t

SELECT count(DISTINCT key) FROM t

SELECT count(DISTINCT key + 5) FROM t

SELECT count(DISTINCT key) FROM (SELECT key FROM t ORDER BY 1 LIMIT 10);
```
nullchecks