My team added a new field in our DynamoDB and I need to add an integer for all entries that do not currently contain the field.
I've tried using the Update example here, however I am getting a ValidationException: Where clause does not contain a mandatory equality on all key attributes
as my WHERE
clause does not include the primary key. However, I do not need to filter by primary key as I only care about entries who do not have a value for the new column.
The query I'm running is PartiQL is:
UPDATE <table-name>
SET <new-field>=0
WHERE NOT <new-field>=0;
The PartiQL UPDATE
WHERE
clause must identify a single DyanmoDB item. As the docs say:
You can only update one item at a time; you cannot issue a single DynamoDB PartiQL statement that updates multiple items. For information on updating multiple items, see Performing Transactions with PartiQL for DynamoDB or Running Batch Operations with PartiQL for DynamoDB.
What this means in practice is that you (1) scan
for all the target records and (2) then issue a UPDATE
statement for each record, ideally batched together.