Cannot restrict PRIMARY KEY part bucket_id by IN relation as a collection is selected by the query

2013-11-07 Thread pavli...@gmail.com
Hey guys, just started to learn Cassandra recently, got a simple
(hopefully) question on querying.

There's a table with composite primary key - mdid and bucket_id. So I
assume mdid is going to be a partition key and bucket_id is a clustering
key. There're also two more columns to hold a text and a map. See
http://pastie.org/private/fcygmm891hgg4ugyjhtjg for a full picture.

So, I am basically going to have a big row with may buckets. In my
application I am going to retrieve a subset of buckets, not all of them at
once, so I do this:

select  where mdid='1' and bucket_id in ('global_props', 'test_bucket')


But that gives the error in the subject.

There's pretty interesting thing is that if I query for text column then
the query works, while does not work for the map column. Check the two
queries at the bottom http://pastie.org/private/fcygmm891hgg4ugyjhtjgplease.

Should this be modelled in a different way in Cassandra? Could you please
advice?

Thanks,
Pavlo


How would you model that?

2013-11-08 Thread pavli...@gmail.com
Hey guys, I need to retrieve a list of distinct users based on their
activity datetime. How can I model a table to store that kind of
information?

The straightforward decision was this:

CREATE TABLE user_activity (user text primary key, ts timeuuid);

but it turned out it is impossible to do a select like this:

select * from user_activity order by ts;

as it fails with "ORDER BY is only supported when the partition key is
restricted by an EQ or an IN".

How would you model the thing? Just need to have a list of users based on
their last activity timestamp...

Thanks!