StatementContext context = new StatementContext(select, connection, resolver, binds, scan);
// Short circuit out if we're compiling an index query and the index isn't active.
// We must do this after the ColumnResolver resolves the table, as we may be updating the local
// cache of the index table and it may now be inactive.
if (tableRef.getTable().getType() == PTableType.INDEX && tableRef.getTable().getIndexState() != PIndexState.ACTIVE) {
return new DegenerateQueryPlan(context, select, tableRef);
}
Integer limit = LimitCompiler.compile(context, select);
GroupBy groupBy = GroupByCompiler.compile(context, select);
// Optimize the HAVING clause by finding any group by expressions that can be moved