I have a Cassandra "table" like the following:
CREATE TABLE example
(
result_id INT,
evaluator_id INT,
score DOUBLE,
PRIMARY KEY(result_id, evaluator_id));
);
And a query like the following:
SELECT result_id, evaluator_id, score FROM example;
I understand that when querying a single partition key, the results will be sorted by the clustering key in the defined order. However to support my data model I'm making the assumption that in the previous unrestricted query, the results will be grouped together by the partition_key "result_id", i.e.,
for row in queryResults:
resultId = row['result_id']
if resultId == lastResultId:
# append the score and evaluator id to a data structure
else:
# do something with the data structure, assuming we've now
# received all scores for the given result_id
lastResultId = resultId
Is this a valid assumption? It makes sense given the storage details, and works in prototype, but doesn't seem to be explicitly guaranteed anywhere. E.g., if I'm pulling data from multiple nodes, could the rows with different result IDs be hypothetically intermixed?