Initial query rewrite support.

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

(nit) leave an empty line between case class and object