Search code examples
cassandraunix-timestampcqlcql3

Recovering date from cassandra sstable2json


I am trying to recover timestamp from a sstable2json dump of a cassandra table for batch processing. The table schema looks something like this:

CREATE TABLE actions  (
userid text,
action text,
ts timestamp,
PRIMARY KEY (userid, ts)
) WITH CLUSTERING ORDER BY (ts DESC);

The sstable2json dump of a particular user looks something like this:

{"key": "HEX_VALUE_OF_USERID","columns": [["2013-07-10 19\\:25\\:44+0000:","",1373484344552000], ["2013-07-10 19\\:44\\:11+0000:action","blog",1373484344552000]]},

When I look up the same user details in the database, with the datetime ("2013-07-10 19:25:44+0000") recovered from the dump, I find no matching records. However, I can find the matching record by using a range query with the recovered datetime (+/-1 sec). Is it possible to recover the actual ts (I am guessing with milliseconds) in someway ?. The other timestamps attached to the row are not consistent (can differ from the ts by some milliseconds). I am using cassandra 1.2.6 and no secondary columns exist.


Solution

  • Answering my own question:

    The issue is with the JdbcDate format (an iso format). None of the formats available seem to provide the ms. The fix was to add a new format for date with ms (add .SSS to the default) and also make the updated format the default - this enabled recovery of the ms.