Setting and resetting counter columns

In certain situations, we might want to set a counter column directly; for instance, if we are backfilling our daily_status_update_views table from historical information in status_update_views, one approach would be to calculate the view counts for each day in our application and then write the counts directly to daily_status_ update_views.

The natural way to do this would be to issue an INSERT statement to put the known total view count in the row for a given day:

INSERT INTO "daily_status_update_views" ("year", "date", "total_views") VALUES (2014, '2014-02-01 00:00:00+0000', 500);

However, if we try to perform this operation, we'll see an error:

As it turns out, the only way to mutate a counter ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.