[
https://issues.apache.org/jira/browse/CASSANDRA-17704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17567362#comment-17567362
]
Abe Ratnofsky commented on CASSANDRA-17704:
-------------------------------------------
> The example with partition key is different because you do never specify the
> partition key in the ORDER BY clause.
Can you elaborate on why the partition key is required in the ORDER BY? If the
partition and clustering prefix are specified by equality or membership (IN),
it should be feasible to sort by the subsequent unspecified clustering columns,
since only a merge sort is required to combine the sorted results for the
specified partition and clustering prefix.
I have a patch that I’m testing that shows this behavior working - could you
re-open this ticket for me to submit the patch? I can also take the
documentation ticket.
> Cannot specify ORDER BY of clustering columns after IN-clause constraints on
> clustering prefix
> ----------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-17704
> URL: https://issues.apache.org/jira/browse/CASSANDRA-17704
> Project: Cassandra
> Issue Type: Bug
> Components: CQL/Semantics
> Reporter: Abe Ratnofsky
> Assignee: Abe Ratnofsky
> Priority: Normal
>
> When a user specifies a partition key and clustering key prefix with equality
> predicates, C* supports sorting by the next clustering key (CASSANDRA-10271):
> {code:java}
> SELECT * FROM tbl WHERE pk = 1 AND ck1 = 1 ORDER BY ck2;{code}
>
> 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):
> {code:java}
> SELECT * FROM tbl WHERE pk IN (1, 2) ORDER BY ck1;{code}
>
> 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:
> {code:java}
> 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
> {code}
>
> 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]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]