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
已提问 3 年前333 查看次数
1 回答
0

See edit

ewok
已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则