Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete multiple elements from a MAP in cassandra?

I have a field cat_to_pub with type as MAP.

{1: '9-20-21', 2: '2-5-21', 4: '2-5-21', 5: '2', 6: '2', 9: '2-83-153-149', 11: '2-5-21-31', 29: '100', 32: '113-198-21'}

I can delete an individual element from this MAP by using

DELETE cat_to_pub[1] FROM user_preferences  WHERE user_id = 'jayeshjain';

How do I remove multiple elements from this set?

for example.if I want to remove key 1 and 2,how do I form my query?

like image 564
HIRA THAKUR Avatar asked May 07 '15 14:05

HIRA THAKUR


People also ask

How do I delete multiple rows in Cassandra?

To delete more than one row, use the keyword IN and supply a list of values in parentheses, separated by commas: DELETE FROM cycling. cyclist_name WHERE firstname IN ('Alex', 'Marianne'); CQL supports an empty list of values in the IN clause, useful in Java Driver applications.

How do I remove all entries from a table in Cassandra?

To remove all rows from a CQL Table, you can use the TRUNCATE command: TRUNCATE keyspace_name.

Is Cassandra good for deletes?

Cassandra's processes for deleting data are designed to improve performance, and to work with Cassandra's built-in properties for data distribution and fault-tolerance. Cassandra treats a delete as an insert or upsert. The data being added to the partition in the DELETE command is a deletion marker called a tombstone.

How remove works Cassandra?

In Cassandra, deleted data is not immediately purged from the disk. Instead, Cassandra writes a special value, known as a tombstone, to indicate that data has been deleted. Tombstones prevent deleted data from being returned during reads, and will eventually allow the data to be dropped via compaction.


1 Answers

With newer version of cassandra (tried with 3.7) you could update user_preference set cat_to_pub = cat_to_pub - { 1, 2 } where user_id = 'jayeshjain';

like image 160
David Kago Avatar answered Oct 12 '22 08:10

David Kago