Sunday, December 06, 2015

Cassandra - How to show column write timestamp


We all know that columns in Cassandra actually have a third aspect: the timestamp, which records the last time the column was updated. But this is not an automatic metadata property, clients have to/should provide the timestamp along with the value when they perform write operations. The timestamp is used purely for conflict resolution on the server side.

But in case you want to know the timestamp for a column, there are ways to show it. In cassandra-cli, you can usually do a "get Hotelier.Hotel['NYN_042']" to see timestamps of each column, but how about in cqlsh? I am using cqlsh spec "3.3.1". You can query a timestamp in cqlsh by issue the following command:

cqlsh:mykeyspace> select key,name,writetime(name) from Hotel where key='CAS_021';
 key     | name    | writetime(name)
---------+---------+------------------
 CAS_021 | W Hotel | 1449445317671115
(1 rows)

No comments: