Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-17704

Cannot specify ORDER BY of clustering columns after IN-clause constraints on clustering prefix

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • None
    • CQL/Semantics
    • None
    • All
    • None

    Description

      When a user specifies a partition key and clustering key prefix with equality predicates, C* supports sorting by the next clustering key (CASSANDRA-10271):

      SELECT * FROM tbl WHERE pk = 1 AND ck1 = 1 ORDER BY ck2;

       
      When a user specifies a partition key with a set-membership predicate, C* supports sorting by the next clustering key (requires merge sort of results for each pk):

      SELECT * FROM tbl WHERE pk IN (1, 2) ORDER BY ck1;

       
      But when a user specifies a partition key with an equality predicate and a clustering key prefix with a set membership predicate, C* does not support sorting by the next clustering key:

      SELECT * FROM tbl WHERE pk = 1 AND ck1 IN (1, 2) ORDER BY ck2;
      org.apache.cassandra.exceptions.InvalidRequestException: Order by currently only supports the ordering of columns following their declared order in the PRIMARY KEY
      

       
      This last situation requires a merge sort, but so does the multi-pk situation.
       
      The docs seem to indicate that this pattern is supported, as well: https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useQueryIN.html

      Attachments

        Activity

          People

            aratnofsky Abe Ratnofsky
            aratnofsky Abe Ratnofsky
            Abe Ratnofsky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: