Add query rewrite support for where, group by and nested expressions.