mike-tr-adamson commented on code in PR #2673:
URL: https://github.com/apache/cassandra/pull/2673#discussion_r1340216519


##########
src/java/org/apache/cassandra/cql3/statements/SelectStatement.java:
##########
@@ -1133,13 +1149,13 @@ public SelectStatement prepare(ClientState state, 
boolean forView) throws Invali
             List<Selectable> selectables = 
RawSelector.toSelectables(selectClause, table);
             boolean containsOnlyStaticColumns = selectOnlyStaticColumns(table, 
selectables);
 
-            StatementRestrictions restrictions = prepareRestrictions(state, 
table, bindVariables, containsOnlyStaticColumns, forView);
+            List<Ordering> orderings = getOrderings(table);
+            StatementRestrictions restrictions = prepareRestrictions(state, 
table, bindVariables, orderings, containsOnlyStaticColumns, forView);
 
             // If we order post-query, the sorted column needs to be in the 
ResultSet for sorting,
             // even if we don't ultimately ship them to the client 
(CASSANDRA-4911).
-            Map<ColumnMetadata, Boolean> orderingColumns = 
getOrderingColumns(table);
-            Set<ColumnMetadata> resultSetOrderingColumns = 
restrictions.keyIsInRelation() ? orderingColumns.keySet()
-                                                                               
           : Collections.emptySet();
+            Map<ColumnMetadata, Ordering> orderingColumns = 
getOrderingColumns(orderings);
+            Set<ColumnMetadata> resultSetOrderingColumns = 
getResultSetOrdering(restrictions, orderingColumns);

Review Comment:
   This failure is reproducible without SAI involved at all. The following test 
also fails on the `cassandra-5.0` branch:
   ```
   @Test
   public void test2() throws IOException
   {
       try (Cluster cluster = init(Cluster.build(1).start()))
       {
           cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (k int, c int, 
v int, primary key(k, c))"));
   
           cluster.coordinator(1).execute(withKeyspace("INSERT INTO %s.t (k, c, 
v) VALUES (0, 1, 2)"), ConsistencyLevel.QUORUM);
   
           String query = withKeyspace("SELECT v FROM %s.t WHERE k IN (0, 1) 
ORDER BY c LIMIT 10");
           assertRows(cluster.coordinator(1).execute(query, 
ConsistencyLevel.ONE), row(2));
       }
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to