Reputation: 11320
I'm trying to scan a dynamo db table based on a value of a list item that has value
in it's name. The field is
"TPMS.value": {
"L": [
{
"N": "0"
},
{
"N": "0"
},
{
"N": "0"
},
{
"N": "0"
}
]
}
and I'd like to get results where TPMS.value[0] != 0
I've tried
aws dynamodb scan \
--table-name afdcm-app-demo-Telemetry-Int_Table \
--filter-expression "TPMS.value[0] > :val" \
--expression-attribute-values '{":val":{"N":"0"}}'
but I keep getting Invalid FilterExpression: Attribute name is a reserved keyword; reserved keyword: value
. Is there a way to run the scan where field name contains value
?
Upvotes: 0
Views: 865
Reputation: 4077
You must use the --expression-attribute-names option. According to documentation (https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html):
One or more substitution tokens for attribute names in an expression. The following are some use cases for using ExpressionAttributeNames :
To access an attribute whose name conflicts with a DynamoDB reserved word.
To create a placeholder for repeating occurrences of an attribute name in an expression.
To prevent special characters in an attribute name from being misinterpreted in an expression.
So in your case the command should be similar to this:
aws dynamodb scan --table-name afdcm-app-demo-Telemetry-Int_Table --filter-expression "#VAL[0] > :val" --expression-attribute-names '{"#VAL":"TPMS.value"}' --expression-attribute-values '{":val":{"N":"0"}}'
Upvotes: 1