Made changes to add support for creating a rewritable query out of sql
Made changes to properly aggregate values from the queries executed on
multiple nodes.