You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Clint Kelly <cl...@gmail.com> on 2014/02/09 03:09:32 UTC

CQL3 delete using < or > ?

Folks,

Is there any way to perform a delete in CQL of all rows where a
particular columns (that is part of the primary key) is less than a
certain value?  I believe that the corresponding SELECT statement
works, as in this example:

cqlsh:fiddle> describe table foo;

CREATE TABLE foo (
  key text,
  fam text,
  qual text,
  version int,
  val text,
  PRIMARY KEY (key, fam, qual, version)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='99.0PERCENTILE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

cqlsh:fiddle> select * from foo;

 key   | fam  | qual | version | val
-------+------+------+---------+--------
 Clint | info | hair |       5 |  brown
 Clint | info | hair |      10 | blonde

(2 rows)

cqlsh:fiddle> select val from foo where key='Clint' and fam='info' and
qual='hair' and version <= 5;

 val
-------
 brown

(1 rows)

cqlsh:fiddle> delete val from foo where key='Clint' and fam='info' and
qual='hair' and version <= 5;
Bad Request: Invalid operator LTE for PRIMARY KEY part version


I assume the only way I can implement the functionality I'm looking
for is to do a select, get a list of all of the elements that I want
to delete, and then delete them in a big batch statement.  Is that
correct?

Thanks!

Best regards,
Clint

Re: CQL3 delete using < or > ?

Posted by Manoj Khangaonkar <kh...@gmail.com>.
Hi ,

>From CQL documentation , for the CQL delete statement , the only allowed
row specifications are

primary_key_name = key_value
primary_key_name IN ( *key_value, key_value, ...*)

regards




On Sat, Feb 8, 2014 at 6:09 PM, Clint Kelly <cl...@gmail.com> wrote:

> Folks,
>
> Is there any way to perform a delete in CQL of all rows where a
> particular columns (that is part of the primary key) is less than a
> certain value?  I believe that the corresponding SELECT statement
> works, as in this example:
>
> cqlsh:fiddle> describe table foo;
>
> CREATE TABLE foo (
>   key text,
>   fam text,
>   qual text,
>   version int,
>   val text,
>   PRIMARY KEY (key, fam, qual, version)
> ) WITH
>   bloom_filter_fp_chance=0.010000 AND
>   caching='KEYS_ONLY' AND
>   comment='' AND
>   dclocal_read_repair_chance=0.000000 AND
>   gc_grace_seconds=864000 AND
>   index_interval=128 AND
>   read_repair_chance=0.100000 AND
>   replicate_on_write='true' AND
>   populate_io_cache_on_flush='false' AND
>   default_time_to_live=0 AND
>   speculative_retry='99.0PERCENTILE' AND
>   memtable_flush_period_in_ms=0 AND
>   compaction={'class': 'SizeTieredCompactionStrategy'} AND
>   compression={'sstable_compression': 'LZ4Compressor'};
>
> cqlsh:fiddle> select * from foo;
>
>  key   | fam  | qual | version | val
> -------+------+------+---------+--------
>  Clint | info | hair |       5 |  brown
>  Clint | info | hair |      10 | blonde
>
> (2 rows)
>
> cqlsh:fiddle> select val from foo where key='Clint' and fam='info' and
> qual='hair' and version <= 5;
>
>  val
> -------
>  brown
>
> (1 rows)
>
> cqlsh:fiddle> delete val from foo where key='Clint' and fam='info' and
> qual='hair' and version <= 5;
> Bad Request: Invalid operator LTE for PRIMARY KEY part version
>
>
> I assume the only way I can implement the functionality I'm looking
> for is to do a select, get a list of all of the elements that I want
> to delete, and then delete them in a big batch statement.  Is that
> correct?
>
> Thanks!
>
> Best regards,
> Clint
>



-- 
http://khangaonkar.blogspot.com/

Re: CQL3 delete using < or > ?

Posted by DuyHai Doan <do...@gmail.com>.
Hello Clint

Deletion in CQL3 using inequality on clustering columns is technically
possible on server side with RangeTombsone.

Unfortunately this is not exposed as API neither in Thrift nor in CQL3.

Create a JIRA to ask for this feature if it is critical for you.

Regards

Duy Hai DOAN
Le 9 févr. 2014 03:09, "Clint Kelly" <cl...@gmail.com> a écrit :

> Folks,
>
> Is there any way to perform a delete in CQL of all rows where a
> particular columns (that is part of the primary key) is less than a
> certain value?  I believe that the corresponding SELECT statement
> works, as in this example:
>
> cqlsh:fiddle> describe table foo;
>
> CREATE TABLE foo (
>   key text,
>   fam text,
>   qual text,
>   version int,
>   val text,
>   PRIMARY KEY (key, fam, qual, version)
> ) WITH
>   bloom_filter_fp_chance=0.010000 AND
>   caching='KEYS_ONLY' AND
>   comment='' AND
>   dclocal_read_repair_chance=0.000000 AND
>   gc_grace_seconds=864000 AND
>   index_interval=128 AND
>   read_repair_chance=0.100000 AND
>   replicate_on_write='true' AND
>   populate_io_cache_on_flush='false' AND
>   default_time_to_live=0 AND
>   speculative_retry='99.0PERCENTILE' AND
>   memtable_flush_period_in_ms=0 AND
>   compaction={'class': 'SizeTieredCompactionStrategy'} AND
>   compression={'sstable_compression': 'LZ4Compressor'};
>
> cqlsh:fiddle> select * from foo;
>
>  key   | fam  | qual | version | val
> -------+------+------+---------+--------
>  Clint | info | hair |       5 |  brown
>  Clint | info | hair |      10 | blonde
>
> (2 rows)
>
> cqlsh:fiddle> select val from foo where key='Clint' and fam='info' and
> qual='hair' and version <= 5;
>
>  val
> -------
>  brown
>
> (1 rows)
>
> cqlsh:fiddle> delete val from foo where key='Clint' and fam='info' and
> qual='hair' and version <= 5;
> Bad Request: Invalid operator LTE for PRIMARY KEY part version
>
>
> I assume the only way I can implement the functionality I'm looking
> for is to do a select, get a list of all of the elements that I want
> to delete, and then delete them in a big batch statement.  Is that
> correct?
>
> Thanks!
>
> Best regards,
> Clint
>