Delete columns

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete columns

Benyi Wang
In C* 2.1.2, is there a way you can delete without specifying the row key?

create table (
  guid text,
  key1 text,
  key2 text,
  data int
  primary key (guid, key1, key2)
);

delete from a_table where key1='<kv1>' and key2='<kv2>';

I'm trying to avoid doing like this:
* query the table to get guids (32 bytes long) 
* send back delete queries like this

delete from a_table where guid in (...) and key1='<kv1>' and kye2='<kv2>'.

key1 and key2 only have 3~4 values, if I try to create multiple tables like table_kvi_kvj, it will be easy to delete, but results in the large dataset because of the duplicated guids.

Because the CQL model will create a cassandra column family like 

guid, kv1-kv2, .., kvi-kvj, ..., kvn-kvm, ...

Is there an API can drop columns in a column familty?
Jan
Reply | Threaded
Open this post in threaded view
|

Re: Delete columns

Jan
Benyi ; 

have you considered using the TTL option in case your columns are meant to be deleted after a predetermined amount of time ? 
Its probably the easiest way to get the task accomplished.

cheers
Jan



On Friday, February 27, 2015 10:38 AM, Benyi Wang <[hidden email]> wrote:


In C* 2.1.2, is there a way you can delete without specifying the row key?

create table (
  guid text,
  key1 text,
  key2 text,
  data int
  primary key (guid, key1, key2)
);

delete from a_table where key1='<kv1>' and key2='<kv2>';

I'm trying to avoid doing like this:
* query the table to get guids (32 bytes long) 
* send back delete queries like this

delete from a_table where guid in (...) and key1='<kv1>' and kye2='<kv2>'.

key1 and key2 only have 3~4 values, if I try to create multiple tables like table_kvi_kvj, it will be easy to delete, but results in the large dataset because of the duplicated guids.

Because the CQL model will create a cassandra column family like 

guid, kv1-kv2, .., kvi-kvj, ..., kvn-kvm, ...

Is there an API can drop columns in a column familty?