On Wed, Jun 19, 2013 at 7:47 AM, Ben Boule <ben_bo...@rapid7.com> wrote:
> Can anyone explain this to me? I have been looking through the source > code but can't seem to find the answer. > > The documentation mentions using the token() function to change a value > into it's token for use in queries. It always mentions it as taking a > single parameter: > > SELECT * FROM posts WHERE token(userid) > token('tom') AND token(userid) < > token('bob') > > > However on my 1.2.5 node I am getting the following error: > > e.x. > > create table foo ( > organization text, > type text, > time timestamp, > id uuid, > primary key ((organization, type, time), id)) > > select * from foo where organization = 'companyA' and type = 'typeB' and > token(time) < token('somevalue') and token(time) > token('othervalue') > > Bad Request: Invalid number of arguments in call to function token: 3 > required but 1 provided > > What are the other two parameters? We don't currently use the token > function but I was experimenting seeing if I could move the time into the > partition key for a table like this to better distribute the rows. But I > can't seem to figure out how to get token() working. > token() acts on the entire partition key, which for you is (organization, type, time), hence the 3 required values. In order to better distribute the rows, I suggest using a time bucket as part of the partition key. For example, you might use only the date portion of the timestamp as the time bucket. These posts talk about doing something similar with the Thrift API, but they will probably still be helpful: - http://rubyscale.com/2011/basic-time-series-with-cassandra/ - http://www.datastax.com/dev/blog/advanced-time-series-with-cassandra -- Tyler Hobbs DataStax <http://datastax.com/>