Bigtable has the capability to Increment values. You can see more details in the protobuf documentation.
Idempotency plays an important role in understanding counters in Bigtable.
In Bigtable, the Puts are generally idempotent, which means that you can run them multiple times and always get the same result (a=2 will produce the same result no matter how many times you run it). Increments are not idempotent, since running them multiple times will produce different results (a++, a++ has a different result than a++, a++, a++).
Transient failures may or may not perform the Increment. It's never clear from the client-side if the Increment succeeds during those transient errors.
This Increment feature is complicated to build in Dataflow because of this idempotency. Dataflow has a concept of "bundles" which is a set of actions that act as a unit of work. Those bundles are retried for transient failures (you can read more about Dataflow transient failure retries here). Dataflow treats that "bundle" as a unit, bug Cloud Bigtable has to treat each individual item in the "bundle" as a distinct transaction, since Cloud Bigtable does not support multi-row transactions.
Given the mismatch in the expected behavior of "bundles", Cloud Bigtable will not allow you to run Increments via Dataflow.
The options you have deserve more documentation than what I can provide here, but I can provide some options at a high level:
Always use Put for any new event you find, and sum up the values on Reads. You can also write another job that does periodic clean up of rows by creating a "transaction" that deletes all current values, and writes a new cell with the sum
Use Cloud Functions which listens to Pub/Sub events and performs Increments. Here's a Cloud Bigtable example using Cloud Functions. You can also perform a Get, perform the addition and do a CheckAndMutate with the algorithm you describe in your post (I personally would opt for CheckAndMutate for consistency, if I were to choose this option).
Use AbstractCloudBigtableTableDoFn to write your own DoFn that performs Increments, or CheckAndMutate, but with the understanding that this may cause data integrity problems.
If the system is large enough, option #1 is your most robust option, but comes at the cost of system complexity. If you don't want that complexity, the option #2 is your next best bet (although I would opt for CheckAndMutate). If you don't care about having data integrity and need high throughput (like "page counts" or other telemetry where it's ok to be wrong a small fraction of the time), then option #3 is going to be your best bet.
add 10 to the spent amount value. Is this something we can do in dataflow?" - Rubén C.UPDATE table SET amount = amount + <new_deposit> WHERE person_id = <person_id>;So, instead of reading it, adding the value and writing it back, I am updating it by issuing increment or update command. - Darshan Mehta