Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS cli - DynamoDb batch-execute-statement return Expected identifier for simple path

I am trying to initially update an item in a table by using the batch-execute-statement as the first try and when that succeeds , add more statements in the file that holds these statements. As of now I have the following

[
  {
    "Statement": "UPDATE 'table_t268468eaf8b64c7b9d3eb2655e98ebd5' SET x=1678976403 WHERE Key='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5' and anotherColumn='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5'"
  }
]

But when running the following

aws dynamodb batch-execute-statement --statements file://batch-execute.json

I am always getting the following error

{
    "Responses": [
        {
            "Error": {
                "Code": "ValidationError",
                "Message": "Statement wasn't well formed, can't be processed: Expected identifier for simple path"
            }
        }
    ]
}

Do you have any idea why ? From what I can see in other examples and documentation I have the right syntax.

Thanks in advance.

like image 825
kostas.kapasakis Avatar asked Jun 28 '26 02:06

kostas.kapasakis


1 Answers

The Key attribute name in your query is actually a DynamoDB reserved word so you'll have to escape and quote it, for example:

SET \"Key\"='fred'

Also, I don't believe that single quotes are allowed with table names (at least they fail for me) so remove the quotes surrounding the table name, for example:

[
  {
    "Statement": "UPDATE table1 SET x=2 WHERE \"Key\"='3' and anotherColumn='4'"
  }
]

Alternatively, use escaped double-quotes around the table name, for example:

[
  {
    "Statement": "UPDATE \"table1\" SET x=2 WHERE \"Key\"='3' and anotherColumn='4'"
  }
]

Finally, ensure that your WHERE clause includes an equality test on all of the primary key attributes (partition key and optional sort key).

like image 137
jarmod Avatar answered Jun 30 '26 11:06

jarmod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!