cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron Little <came...@cloudcitylabs.co>
Subject Delete semantics
Date Fri, 21 Aug 2015 23:41:47 GMT
Can anyone help me understand the semantics of the DELETE cql statement, specifically the WHERE…
part?

Taken literally, the datastax documentation at http://docs.datastax.com/en/cql/3.1/cql/cql_reference/delete_r.html
<http://docs.datastax.com/en/cql/3.1/cql/cql_reference/delete_r.html> seems to indicate
a single row specification can be used. 

The documentation at https://cassandra.apache.org/doc/cql3/CQL.html#deleteStmt <https://cassandra.apache.org/doc/cql3/CQL.html#deleteStmt>
seems to indicate that the row specifications can be in any order.


Here’s what I’ve found so far from testing.

- Identifiers must be primary key columns.
- A single IN clause (<identifier> IN '(' <term_list> ')') is allowed for the
 first primary key column
- Mutliple = clauses (<identifier> '=' <term>) are allowed, starting with the
first primary key column (not already used), not skipping any, and not appearing before an
IN clause

For example, the following work for the table:

CREATE TABLE mpk_store (
  pk_one text,
  pk_two text,
  pk_three text,
  four text,
  PRIMARY KEY (pk_one, pk_two, pk_three)
)

DELETE FROM mpk_store WHERE pk_one IN ('a', 'b') AND pk_two = 'a';
DELETE FROM mpk_store WHERE pk_one IN ('a', 'b') AND pk_two = 'a' AND pk_three = 'b';
DELETE FROM mpk_store WHERE pk_one IN ('a', 'b');
DELETE FROM mpk_store WHERE pk_one = 'a';

The following return Bad Request errors:

DELETE FROM mpk_store WHERE pk_one IN ('a', 'b') AND pk_two IN ('a', 'b');
DELETE FROM mpk_store WHERE pk_one = 'test_fetch_partial_limit' AND pk_two IN ('a', 'b');
DELETE FROM mpk_store WHERE pk_one IN ('a', 'b') AND pk_two IN ('a', 'b') AND pk_three = 'b';

This is a bit weird, since select allows IN clauses anywhere in the statement.


Can anyone help explain these semantics or why Cassandra does this?

Thanks,
Cameron Little


Mime
View raw message