Issue
I'm trying to perform a dynamodb table scan with some filter expression. Current filter expression has a condition of begins_with something like :
import os
import boto3
from boto3.dynamodb.conditions import Attr
env_id = os.environ['ENVIRONMENT']
buId = '10014'
# Define the table
table = boto3.resource('dynamodb').Table(env_id+'-abcd')
response = table.scan(
ProjectionExpression='#SubsId,#ItemId,#SeqNum',
ExpressionAttributeNames={
'#SubsId' : 'SubsId', # partition key
'#ItemId' : 'ItemId', # sort key
'#SeqNum' : 'SeqNum' # sequence number
},
FilterExpression=Attr('SubsId').begins_with(buId) AND //SeqNum Not Exists
)
In the FilterExpression I want to check if
SeqNum Not Exists
Can someone help me with how can I add that after AND condition on the above code?
Solution
You can use '&' for AND
and '|' for OR
(doc). Your filter expression will look like this:
FilterExpression=Attr('SubsId').begins_with(buId) & Attr('SeqNum').not_exists()
Answered By - hoangdv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.