String tableName = '"' + index.getTableName().getString() + '"';
List<? extends TableNode> tables = Collections.singletonList(FACTORY.namedTable(alias, FACTORY.table(schemaName, tableName)));
try {
SelectStatement indexSelect = FACTORY.select(select, tables);
QueryCompiler compiler = new QueryCompiler(statement, targetColumns, parallelIteratorFactory);
QueryPlan plan = compiler.compile(indexSelect);
// Checking the index status and number of columns handles the wildcard cases correctly
// We can't check the status earlier, because the index table may be out-of-date.
if (plan.getTableRef().getTable().getIndexState() == PIndexState.ACTIVE && plan.getProjector().getColumnCount() == nColumns) {
plans.add(plan);
return true;