incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laing, Michael" <michael.la...@nytimes.com>
Subject Re: Selecting multiple rows with composite partition keys using CQL3
Date Wed, 04 Sep 2013 18:35:31 GMT
you could try this. -ml

-- put this in <file> and run using 'cqlsh -f <file>

DROP KEYSPACE carl_test;

CREATE KEYSPACE carl_test WITH replication = {
    'class': 'SimpleStrategy',
    'replication_factor' : 1
};

USE carl_test;

CREATE TABLE carl_table (
    app text,
    name text,
    ts int,
    data  text,
    PRIMARY KEY ((app, name), ts)
);

update carl_table set data = 'whatever' where app='foo' and name='bar' and
ts=123;
update carl_table set data = 'whomever' where app='foo' and name='hello'
and ts=123;

SELECT * FROM carl_table WHERE app='foo' and name in ('bar', 'hello') and
ts=123;

-- returns:

-- app | name  | ts  | data
-------+-------+-----+----------
-- foo |   bar | 123 | whatever
-- foo | hello | 123 | whomever



On Wed, Sep 4, 2013 at 1:33 PM, Carl Lerche <me@carllerche.com> wrote:

> I can't find a way to do this with the current implementation of CQL3. Are
> there any plans to add an OR feature to CQL3 or some other way to select a
> batch of disjoint composite keys?
>
>
> On Fri, Aug 30, 2013 at 7:52 PM, Carl Lerche <me@carllerche.com> wrote:
>
>> Hello,
>>
>> I've been trying to figure out how to port my application to CQL3 based
>> on http://cassandra.apache.org/doc/cql3/CQL.html.
>>
>> I have a table with a primary key: ( (app, name), timestamp ). So, the
>> partition key would be composite (on app and name). I'm trying to figure
>> out if there is a way to select multiple rows that span partition keys.
>> Basically, I am trying to do:
>>
>> SELECT .. WHERE (app = 'foo' AND name = 'bar' AND timestamp = 123) OR
>> (app = 'foo' AND name='hello' AND timestamp = 123)
>>
>
>

Mime
View raw message