SelectStatement statement = parser.parseQuery();
Scan scan = new Scan();
PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class);
ColumnResolver resolver = FromCompiler.getResolver(statement, pconn);
statement = StatementNormalizer.normalize(statement, resolver);
context = new StatementContext(new PhoenixStatement(pconn), resolver, binds, scan);
GroupBy groupBy = GroupByCompiler.compile(context, statement);
// Optimize the HAVING clause by finding any group by expressions that can be moved
// to the WHERE clause
statement = HavingCompiler.rewrite(context, statement, groupBy);