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?
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.
To remove all rows from a CQL Table, you can use the TRUNCATE command: TRUNCATE keyspace_name.
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.
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.
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With