Search code examples
cassandracql3cqlsh

run a bulk update query in cassandra on 1 column


we have a scenario where a table in cassandra which has over million records and we want execute a bulk update on a column(basically set the column value to null in entire table).

is there a way to do so since below query won't work in CQL

UPDATE TABLE_NAME SET COL1=NULL WHERE PRIMARY_KEY IN(SELECT PRIMARY_KEY FROM TABLE_NAME );

P.S - the column is not a primary key or a cluster key.


Solution

  • There has been a similar question the other days regarding Deleting a column in cassandra for a large dataset...I suggest also reading the section Dropping a column from the Alter table documentation.

    One solution in this case might be dropping the column and re-adding it since

    If you drop a column then re-add it, Cassandra does not restore the values written before the column was dropped. A subsequent SELECT on this column does not return the dropped data.

    I would test this on a test system beforehand and I would check if the tombstones have been removed.