DynamoDB local GSI KeyConditionExpression difference from live Dynamo

0

I'm running some tests with dynamodb local and live dynamo. When I use a KeyConditionExpression, only the hash key is allowed with live dynamo and to filter results based on the sort key I have to use a FilterExpression. In dynamodb local, the opposite is true. I want my code to be the same for my local tests and in production, but it doesn't seem possible with this difference. Here's some example code:

table = boto3.resource('dynamodb').Table('tablename')  
# Table has hash/sort keys of `hash` and `sort`  
# GSI of table has hash/sort keys of `gsihash` and `sort`  
# Works with dynamodb local, throws an error with live dynamo  
table.query(KeyConditionExpression=Key('hash').eq('somevalue') & Key('sort').begins_with('someprefix'), IndexName='GSI')  
# Works with live dynamo, throws an error with dynamodb local  
table.query(KeyConditionExpression=Key('hash').eq('somevalue'), FilterExpression=Attr('sort').begins_with('someprefix'), IndexName='GSI')  

Edited by: ewok on Dec 29, 2020 7:30 AM

Edited by: ewok on Dec 29, 2020 8:33 AM

Nevermind, was a difference in the table definition locally vs live

ewok
gefragt vor 3 Jahren333 Aufrufe
1 Antwort
0

See edit

ewok
beantwortet vor 3 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen