Initial query rewrite support.

Currently supports matching columns, literals and count(*) in the selection
and columns in grouping.


@rjmac I forgot how to do it exactly.  But I would argue in this case that testability, composability and readability are more important.   Actually you can still get exhaustiveness checking, I think, when you compose the partials, but I'd have to try it.

Ah sorry, it's something like `partialMatches(expr) orElse fcMatches(expr) orElse ....`