adelapena commented on code in PR #2673:
URL: https://github.com/apache/cassandra/pull/2673#discussion_r1348664357


##########
src/java/org/apache/cassandra/cql3/statements/SelectStatement.java:
##########
@@ -281,14 +287,27 @@ public ResultMessage.Rows execute(QueryState state, 
QueryOptions options, long q
 
         Selectors selectors = selection.newSelectors(options);
         AggregationSpecification aggregationSpec = getAggregationSpec(options);
-        ReadQuery query = getQuery(options, state.getClientState(), 
selectors.getColumnFilter(),
-                                   nowInSec, userLimit, userPerPartitionLimit, 
pageSize, aggregationSpec);
+        DataLimits limit = getDataLimits(userLimit, userPerPartitionLimit, 
pageSize, aggregationSpec);

Review Comment:
   I think `PER PARTITION LIMIT` doesn't work with vsearch. That's because 
index uses `readCommand.limits().count()` but ignores 
`readCommand.limits().perPartitionCount()`. This example shows how it returns 
wrong results:
   ```java
   try (Cluster cluster = init(Cluster.build(2).withConfig(config -> 
config.with(GOSSIP, NETWORK)).start()))
   {
       cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (k int, c int, v 
vector<float, 2>, PRIMARY KEY (k, c))"));
       cluster.schemaChange(withKeyspace("CREATE CUSTOM INDEX ON %s.t(v) USING 
'StorageAttachedIndex' WITH OPTIONS = { 'similarity_function': 'EUCLIDEAN'}"));
       SAIUtil.waitForIndexQueryable(cluster, KEYSPACE);
   
       ICoordinator coordinator = cluster.coordinator(1);
       coordinator.execute(withKeyspace("INSERT INTO %s.t (k, c, v) VALUES (1, 
1, [0, 4])"), ALL);
       coordinator.execute(withKeyspace("INSERT INTO %s.t (k, c, v) VALUES (1, 
2, [0, 3])"), ALL);
       coordinator.execute(withKeyspace("INSERT INTO %s.t (k, c, v) VALUES (2, 
1, [0, 2])"), ALL);
       coordinator.execute(withKeyspace("INSERT INTO %s.t (k, c, v) VALUES (2, 
2, [0, 1])"), ALL);
   
       assertRows(coordinator.execute(withKeyspace("SELECT * FROM %s.t PER 
PARTITION LIMIT 1 LIMIT 100"), ONE),
                  row(1, 1, vector(0f, 4f)),
                  row(2, 1, vector(0f, 2f)));
   
       assertRows(coordinator.execute(withKeyspace("SELECT * FROM %s.t ORDER BY 
v ANN OF [0, 0] PER PARTITION LIMIT 1 LIMIT 100"), ONE),
                  row(2, 2, vector(0f, 1f)),
                  row(1, 2, vector(0f, 3f))); // returns [[2, 1, [0.0, 2.0]], 
[1, 1, [0.0, 4.0]]]
   
       assertRows(coordinator.execute(withKeyspace("SELECT * FROM %s.t PER 
PARTITION LIMIT 1 LIMIT 1"), ONE),
                  row(1, 1, vector(0f, 4f)));
   
       assertRows(coordinator.execute(withKeyspace("SELECT * FROM %s.t ORDER BY 
v ANN OF [0, 0] PER PARTITION LIMIT 1 LIMIT 1"), ONE),
                  row(2, 2, vector(0f, 1f)));
   }
   ```
   We should probably forbid it and add it to the list of unsupported features 
in the warning message.



-- 
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