Reputation: 1068
Given a table with a composite partition key like:
CREATE TABLE testtable (
column1 text,
column2 text,
column3 text,
column4 text,
column5 text,
column6 text,
PRIMARY KEY ((column1, column2, column3, column4))
)
How could I get all the unique values of only one partition column? Now, I know this doesn't work:
SELECT DISTINCT column2 from testtable;
However, I can do
SELECT DISTINCT column1, column2, column3, column4 from testtable;
So, is there a way (within CQL because the result of that query might be quite large) to query that query result like you would do in SQL? Something like this:
SELECT DISTINCT column2 FROM (SELECT DISTINCT column1, column2, column3, column4 from testtable);
Which doesn't work. Or do I really have to use Python (or other alternatives) for this?
Upvotes: 0
Views: 500
Reputation: 6717
Simply put, there is no way to achieve this in CQL. The entirety of the partitioning key defines which Cassandra node is responsible for handling the data, and queries on it. Therefore, it always has to be given in its entirety.
Upvotes: 2