private void processOrderingClause(SelectStatement stmt, CFMetaData cfm) throws InvalidRequestException { verifyOrderingIsAllowed(stmt); // If we order post-query (see orderResults), the sorted column needs to be in the ResultSet for sorting, even if we don't // ultimately ship them to the client (CASSANDRA-4911). if (stmt.keyIsInRelation) { stmt.orderingIndexes = new HashMap<>(); for (ColumnIdentifier.Raw rawColumn : stmt.parameters.orderings.keySet()) { ColumnIdentifier column = rawColumn.prepare(cfm); final ColumnDefinition def = cfm.getColumnDefinition(column); if (def == null) handleUnrecognizedOrderingColumn(column); int index = stmt.selection.getResultSetIndex(def); if (index < 0) index = stmt.selection.addColumnForOrdering(def); stmt.orderingIndexes.put(def.name, index); } } stmt.isReversed = isReversed(stmt, cfm); }