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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠