kreynolds/cassandra-cql — Issue #19: There needs to be a way to get back TimeUUID column keys as TimeUUID
Author: twhaples
Created: 2011-10-12 17:23:42+00:00
State: open

We've got some data in our Cassandra data store. Some of it is useful data.
Other parts we've determined to be useless. We'd like to delete the useless
parts.

Normally, the approach here would be to scan over the data, look for the
useless parts in the columns' data, then delete the columns which contain
that data. Unfortunately, the columns are indexed by TimeUUID. cassandra-cql
attempts to be helpful and return the column name as a Time value, instead
of a TimeUUID. This means that there's **no way** to get back the TimeUUID
needed in order to delete these rows.

We've run into this once in the past and the easiest way to deal with it
turned out to be a monkey-patch to cassandra-cql in the migration script.
Needless to say, this solution is less than ideal.

cassandra-cql needs to provide some mechanism to return the column name
as a TimeUUID when it is a TimeUUID. We don't particularly care whether
this is by the default .column_names mechanism (removing the conversion
code and making people using this gem do it themselves instead) or by
another mechanism, just so long as there's some way to do it when we
need to.

Basic lame script illustrating what we're doing:
```query = Nearbuy::Cassandra.execute("select * from blah_data")
to_delete = {}
while (row = query.fetch)
to_delete[row.key] = []
row.column_names.each_with_index do |colkey, i|
next if i == 0
if lame?(row.column_values[i])
to_delete[row.key] << colkey
end
end
end

to_delete.each_pair do |site_key, col_keys|
next unless col_keys.length
delete_qs = col_keys.map { '?' } .join(',')
res = Nearbuy::Cassandra.execute(
"delete #{delete_qs} from blah_data where key = ?",
*col_keys, # oh no! these aren't the UUIDs we're looking for!
site_key,
)
end
```