You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "pavlikus@gmail.com" <pa...@gmail.com> on 2013/11/07 13:05:44 UTC

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

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

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

Posted by Aaron Morton <aa...@thelastpickle.com>.
The code just says we cannot support it yet, it may come in the future:

                    // We only support IN for the last name and for compact storage so far
                    // TODO: #3885 allows us to extend to non compact as well, but that remains to be done

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


Depends on what you are doing with the map column. 

This is roughly the same as using the map, but in a different table:

CREATE TABLE device_map (
  mdid text,
  bucket_id text,
  map_key	text, 
  map_value text,
  PRIMARY KEY(  (mdid, bucket_id), map_key)
)

Cheers

-----------------
Aaron Morton
New Zealand
@aaronmorton

Co-Founder & Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 8/11/2013, at 1:05 am, pavlikus@gmail.com wrote:

> 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/fcygmm891hgg4ugyjhtjg please.
> 
> Should this be modelled in a different way in Cassandra? Could you please advice?
> 
> Thanks, 
> Pavlo