Hexy
Hexy

Reputation: 857

FilterExpression Syntax error using boto3 dynamodb client

I am trying to query dynamodb using the low-level client api of boto3.

   response = client.query(
        TableName='People',
        IndexName='country-index',
        KeyConditionExpression='country = :country',
        FilterExpression="attribute_not_exists('age') AND attribute_not_exists('address')",
        ExpressionAttributeValues={
            ":country":{"S": "USA"}
        },
        Limit=100
    )

I get a syntax error :

An error occurred (ValidationException) when calling the Query operation: Invalid FilterExpression: Syntax error; token: "'", near: "('age"

The documentation in boto3 redirects to Amazon developer guide. I was not able to find the syntax for client.query(...). The examples listed there are for using table.query(...)

Upvotes: 1

Views: 10228

Answers (1)

notionquest
notionquest

Reputation: 39226

Please change the FilterExpression as mentioned below.

FilterExpression="attribute_not_exists(age) AND attribute_not_exists(address)",

Upvotes: 6

Related Questions