Discussion:
Read data from Cassandra ordered by writetime using cql.
Abhishek Mukherjee
2014-06-17 11:48:26 UTC
Permalink
Hi Everyone,

I am trying to read data from my Cassandra database in the order in which
it got written into the DB. There is a WRITETIME function which gives me
the write time for a column. How can I use this so that the data when I do
a returned from my query gets ordered by write time.

I am trying to achieve something like this:

select column1, column2, column3 from table order by writetime (column4);


Thanks in advance,
Abhishek
subhankar biswas
2014-06-17 12:03:31 UTC
Permalink
this question has been raised several times. But only one answer u can/should not.
Post by Abhishek Mukherjee
Hi Everyone,
I am trying to read data from my Cassandra database in the order in which it got written into the DB. There is a WRITETIME function which gives me the write time for a column. How can I use this so that the data when I do a returned from my query gets ordered by write time.
select column1, column2, column3 from table order by writetime (column4);
Thanks in advance,
Abhishek
Jens Rantil
2014-06-17 12:06:10 UTC
Permalink
Hi Abhishek,

You can't. You need to use a clustering key to keep track of your ordering.
See
http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/select_r.html?scroll=reference_ds_d35_v2q_xj__querying-compound-primary-keys-and-sorting-results

Cheers,
Jens
Post by Abhishek Mukherjee
Hi Everyone,
I am trying to read data from my Cassandra database in the order in which
it got written into the DB. There is a WRITETIME function which gives me
the write time for a column. How can I use this so that the data when I do
a returned from my query gets ordered by write time.
select column1, column2, column3 from table order by writetime (column4);
Thanks in advance,
Abhishek
Abhishek Mukherjee
2014-06-17 12:12:15 UTC
Permalink
Thanks Jen. I'll r
Post by Jens Rantil
Hi Abhishek,
You can't. You need to use a clustering key to keep track of your
ordering. See
http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/select_r.html?scroll=reference_ds_d35_v2q_xj__querying-compound-primary-keys-and-sorting-results
Cheers,
Jens
Post by Abhishek Mukherjee
Hi Everyone,
I am trying to read data from my Cassandra database in the order in which
it got written into the DB. There is a WRITETIME function which gives me
the write time for a column. How can I use this so that the data when I do
a returned from my query gets ordered by write time.
select column1, column2, column3 from table order by writetime (column4);
Thanks in advance,
Abhishek
Abhishek Mukherjee
2014-06-17 12:13:17 UTC
Permalink
Thanks I'll have a look.
Post by Abhishek Mukherjee
Thanks Jen. I'll r
Post by Jens Rantil
Hi Abhishek,
You can't. You need to use a clustering key to keep track of your
ordering. See
http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/select_r.html?scroll=reference_ds_d35_v2q_xj__querying-compound-primary-keys-and-sorting-results
Cheers,
Jens
Post by Abhishek Mukherjee
Hi Everyone,
I am trying to read data from my Cassandra database in the order in
which it got written into the DB. There is a WRITETIME function which gives
me the write time for a column. How can I use this so that the data when I
do a returned from my query gets ordered by write time.
select column1, column2, column3 from table order by writetime (column4);
Thanks in advance,
Abhishek
Loading...