I am testing Cassandra (2.0) as a possible replacement for storing time series data.
I made a simple table and dumped some of our data:
CREATE TABLE DataRaw(
channelId int,
sampleTime timestamp,
value double,
PRIMARY KEY (channelId, sampleTime)
) WITH CLUSTERING ORDER BY (sampleTime ASC);
I can easily execute the most frequently used queries, such as the first value, the last value (current) and get statistics through max, min, count, avg, etc.
But I also need to not only get the maximum value in the range, but also the time in which this value.
For data:
sampleTime value
2015-08-28 00:00 10
2015-08-28 01:00 15
2015-08-28 02:00 13
I want the request returned 2015-08-28 01:00 and 15
I tried something like this:
select sampletime, value from dataraw where channelid=865 and sampletime >= '2014-01-01 00:00' and sampleTime < '2014-01-02 00:00' and value = (select max(value) from dataraw where channelid=865 and sampletime >= '2014-01-01 00:00' and sampleTime < '2014-01-02 00:00');
which will work in "normal" SQL, but he doesn't like Cassandra.
Any ideas?
source
share