使用AWS DynamoDB batch-execute-statement报Expected identifier错误求助
DynamoDB batch-execute-statement 语法错误排查
问题场景
尝试通过batch-execute-statement首次更新DynamoDB表条目,语句文件内容如下:
[ { "Statement": "UPDATE 'table_t268468eaf8b64c7b9d3eb2655e98ebd5' SET x=1678976403 WHERE Key='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5' and anotherColumn='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5'" } ]
执行命令:
aws dynamodb batch-execute-statement --statements file://batch-execute.json
返回错误:
{ "Responses": [ { "Error": { "Code": "ValidationError", "Message": "Statement wasn't well formed, can't be processed: Expected identifier for simple path" } } ] }
错误原因
DynamoDB使用的PartiQL语法中,表名和属性名不能用单引号包裹,单引号仅用于包裹字符串类型的属性值。你的语句里错误地给表名加了单引号,导致语法解析失败。
修正后的语句文件
将表名的单引号移除,属性名保持无引号状态即可:
[ { "Statement": "UPDATE table_t268468eaf8b64c7b9d3eb2655e98ebd5 SET x=1678976403 WHERE Key='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5' AND anotherColumn='e1c09d48-fdc5-41eb-8ca2-f7b4ff8a01c5'" } ]
注:AND关键字建议大写(PartiQL对大小写不敏感,但大写更符合通用语法规范)。
重新执行原命令即可完成更新操作。
内容的提问来源于stack exchange,提问作者kostas.kapasakis
相关产品推荐
相关产品推荐

