Initial query rewrite support.

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

classOf[QueryRewriter] and getClass don't mean the same thing in the presence of subclassing.  Always prefer the former unless you know a class will never be subclassed (in which case you should make it final).