I've got a Cassandra column family (created using Pycassa) with the following schema:
ColumnFamily: tracker
Key Validation Class: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.DateType)
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Cells sorted by: org.apache.cassandra.db.marshal.UTF8Type
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 0.1
DC Local Read repair chance: 0.0
Populate IO Cache on flush: false
Replicate on write: true
Caching: KEYS_ONLY
Bloom Filter FP chance: default
Built indexes: []
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
I'm trying to insert into it with the following line:
self.tracker_batcher.insert(tracker_key, dictionary_to_insert)
where tracker_key
is:
('cd7449e8-8f0d-4730-9ee4-ef60edfdd409', datetime.datetime(2013, 8, 14, 16, 47, 55, 856000))
I'd expect this to work - I use datetypes in other tables as row keys and they work a treat. Additionally - it looks like I'm following the tutorial on the Pycassa site (http://pycassa.github.io/pycassa/assorted/composite_types.html).
For further information I'm using Pycassa version 1.9.0 and Cassandra 1.2.8
Thanks,
Matt
edit:
In a bizarre twist of events, the first error message I receive:
TypeError: A str or unicode value was expected, but datetime was received instead (2013-08-14 16:45:15.376000)
I tried modifying the query as such:
tracker_key = (str(dictionary_to_insert['session_id']), datetime.datetime.strftime(dictionary_to_insert['datestamp'], "%Y-%m-%d %H:%M:%S"))
i.e. changed the datetime to a string
and got the following error message:
raise TypeError('DateType arguments must be a datetime or timestamp')
TypeError: DateType arguments must be a datetime or timestamp
Baffling.