Error: ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;
Answered by Rafal Wilinski
Solution
DynamoDB has a list of reserved keywords that you cannot use in your queries or scans directly. If you need to write an expression that contains one of them, you need to use ExpressionAttributeNames to replace reserved word with a placeholder. For example, this query with reserved keyword:
params = { TableName : ‘MY_TABLE’, FilterExpression: "timestamp BETWEEN :startDate AND :endDate", ExpressionAttributeValues: { ":startDate": ""+startDate, ":endDate": ""+endDate } }
Replace with:
params = { TableName : ‘MY_TABLE’, FilterExpression: "#dynobase_timestamp BETWEEN :startDate AND :endDate", ExpressionAttributeValues: { ":startDate": startDate, ":endDate": endDate }, ExpressionAttributeNames: { "#dynobase_timestamp": "timestamp" } }
Other Common DynamoDB Errors (with Solutions)
- KMS Key Access Denied Error DynamoDB
- dynamodb put function not working
- dynamodb list_append if_not_exists not working
- dynamodb system errors metric
- DynamoDB aliasing is not supported
- could not lookup table in dynamodb
- could not unmarshal the value dynamodb
- failed to list tables not authorized dynamodb
- dynamodb getItem() is not a function
- dynamodb global secondary index not working
- dynamodb the parameter cannot be converted to a numeric value
- dynamodb unable to locate credentials
- dynamodb-admin not working
- dynamodb table not exists
- dynamodb put item not working
Tired of switching accounts and regions? Use Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase