David Capwell created CASSANDRA-19955:
-----------------------------------------

             Summary: Accord should not block partition restricted Index queries
                 Key: CASSANDRA-19955
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19955
             Project: Cassandra
          Issue Type: Bug
          Components: Accord
            Reporter: David Capwell


Accord requires partitions as part of the tracking protocol, which limits the 
use of range queries as no partition is known.  There are valid use cases for 
partition restricted index queries, yet those appear to be range queries which 
causes Accord to block them.

Rather than checking the type of the query, we should check if it has the 
following

1) selects a partition
2) if in LET clause, returns at most 1 run

Partition restricted index queries fit this, so should be allowed in both LET 
and returning SELECT clauses

Below is a test showing this doesn’t work

{code}
CREATE TABLE keyspace_test_00."tbl" (
    "pk1" tinyint,
    "pk2" ascii,
    "ck" frozen<map<frozen<set<date>>, 
'org.apache.cassandra.db.marshal.DynamicCompositeType(p=>org.apache.cassandra.db.marshal.ShortType,n=>org.apache.cassandra.db.marshal.Int32Type,c=>org.apache.cassandra.db.marshal.IntegerType)'>>,
    "s1" frozen<map<frozen<list<inet>>, 
'org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.DecimalType)'>>
 static,
    "s2" set<vector<uuid, 2>> static,
    "v1" 
'org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.TimeUUIDType),org.apache.cassandra.db.marshal.TimeType)',
    "v2" frozen<list<'org.apache.cassandra.db.marshal.LexicalUUIDType'>>,
    PRIMARY KEY (("pk1", "pk2"), "ck")
) WITH CLUSTERING ORDER BY ("ck" ASC);

CREATE INDEX ON keyspace_test_00.”tbl”(v2) USING ’sai’;

BEGIN TRANSACTION
  SELECT *
  FROM keyspace_test_00."tbl"
  WHERE "v2" = ? AND "pk1" = (tinyint) ? - (tinyint) ? AND "pk2" = ?
  LIMIT 1;
COMMIT TRANSACTION;
{code}

Fails with

{code}
Caused by: org.apache.cassandra.exceptions.InvalidRequestException: Range 
queries are not allowed for reads within a transaction; returning select at 
[2:3]
        at 
org.apache.cassandra.cql3.statements.RequestValidations.invalidRequest(RequestValidations.java:370)
        at 
org.apache.cassandra.cql3.statements.RequestValidations.checkTrue(RequestValidations.java:97)
        at 
org.apache.cassandra.cql3.statements.RequestValidations.checkFalse(RequestValidations.java:223)
        at 
org.apache.cassandra.cql3.statements.TransactionStatement$Parsed.checkAtMostOneRowSpecified(TransactionStatement.java:603)
        at 
org.apache.cassandra.cql3.statements.TransactionStatement$Parsed.prepare(TransactionStatement.java:558)
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to