using CF:
CREATE TABLE history (
domain text,
iid text,
timeid timeuuid,
data text,
comments text,
PRIMARY KEY (domain, iid, timeid)
);
I'd like to query it like this:
select domain, iid, timeid, data, comments from mappings
where domain = 'a' and iid = 'b' order by timeid desc;
But it fails with the following error (cassandra 1.1.5):
Bad Request: Order by currently only support the ordering of columns following their declared order in the PRIMARY KEY
Am I doing it wrong? What could be the workaround? Thx
PS I got it working with the single EQ restriction and ORDER BY but I need at least 2 restrictions and order by.
You can change 'order by' column to second column in primary key:
select * from history where domain = 'a' and iid = 'b' order by iid desc;
It is a bit confusing because you restrict iid with equality, but it works - you will get your result sorted by timeid.
I believe this is because iid and timeid form one composite column and when you order by iid in descending order, it orders all composite column components including timeid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With