Skip to content

Instantly share code, notes, and snippets.

@heartofrevel
Created February 1, 2021 19:58
Show Gist options
  • Save heartofrevel/1abf821c4b5e7a192784a81f4fc89d99 to your computer and use it in GitHub Desktop.
Save heartofrevel/1abf821c4b5e7a192784a81f4fc89d99 to your computer and use it in GitHub Desktop.
UPSERT with Update
cqlsh:demo> DESC upsert_test ;
CREATE TABLE demo.upsert_test (
name text PRIMARY KEY,
title text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
cqlsh:demo> SELECT * from upsert_test ;
name | title
------+-------
(0 rows)
cqlsh:demo> UPDATE upsert_test SET title = 'TL' WHERE name = 'Anshul';
cqlsh:demo> SELECT * from upsert_test ;
name | title
--------+-------
Anshul | TL
(1 rows)
cqlsh:demo> UPDATE upsert_test SET title = null WHERE name = 'Anshul';
cqlsh:demo> SELECT * from upsert_test ;
name | title
------+-------
(0 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment