Initial query rewrite support.

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

Instead of `classOf[QueryRewriter]` just use `getClass`, so it survives renames better.