SQL Query Parser and Query Rewriting