cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kai Wang <dep...@gmail.com>
Subject timestamp as clustering key doesn't work as expected
Date Fri, 23 Oct 2015 15:55:52 GMT
Hi,

I use a timestamp column as the last clustering key so that I can run query
like "timestamp > ... AND timestamp < ...". But it doesn't work as
expected. Here is a simplified example.

My table:
CREATE TABLE test (
    tag text,
    group int,
    timestamp timestamp,
    value double,
    PRIMARY KEY (tag, group, timestamp)
) WITH CLUSTERING ORDER BY (group ASC, timestamp DESC)

After inserting some data, here is my query:

cqlsh> select * from test where tag = 'MSFT' and group = 1 and timestamp
='2004-12-15 16:00:00-0500';

 tag  | group | timestamp                | value
------+-------+--------------------------+-------
 MSFT |     1 | 2004-12-15 21:00:00+0000 | 27.11
 MSFT |     1 | 2004-12-16 21:00:00+0000 | 27.16
 MSFT |     1 | 2004-12-17 21:00:00+0000 | 26.96
 MSFT |     1 | 2004-12-20 21:00:00+0000 | 26.95
 MSFT |     1 | 2004-12-21 21:00:00+0000 | 27.07
 MSFT |     1 | 2004-12-22 21:00:00+0000 | 26.98
 MSFT |     1 | 2004-12-23 21:00:00+0000 | 27.01
 MSFT |     1 | 2004-12-27 21:00:00+0000 | 26.85
 MSFT |     1 | 2004-12-28 21:00:00+0000 | 26.95
 MSFT |     1 | 2004-12-29 21:00:00+0000 |  26.9
 MSFT |     1 | 2004-12-30 21:00:00+0000 | 26.76
(11 rows)

This doesn't make sense. I expect this query to return only the first row.
Why does it give me back rows with different timestamps? Did I
misunderstand how timestamp and clustering key work?

Thanks.

-Kai

Mime
View raw message