- Newest
- Most votes
- Most comments
DynamoDB Local does not support the Limit parameter for ExecuteStatement which is likely why you see a discrepancy
The behavior you're describing appears to be a discrepancy between DynamoDB Local and the live DynamoDB service when using PartiQL SELECT statements with descending ordering and a Limit parameter. This is likely a bug in the DynamoDB Local implementation.
In the live DynamoDB service, when using PartiQL SELECT statements with ORDER BY and LIMIT clauses, the expected behavior is to return the first n records after applying the ordering, which is what you're seeing in the live service results.
For your query:
SELECT * FROM MyTable WHERE Hash='Something' ORDER BY Range DESC LIMIT 3
The correct result set should indeed be:
| Hash | Range |
|---|---|
| Something | 5 |
| Something | 4 |
| Something | 3 |
This is because the records are first ordered in descending order by the Range key, and then the top 3 results are returned due to the LIMIT clause.
The behavior you're seeing in DynamoDB Local, where it returns the last 3 records after ordering, is incorrect and inconsistent with the live service. This kind of discrepancy can cause issues when developing and testing applications locally before deploying to the live environment.
It's important to note that while DynamoDB Local is a useful tool for development and testing, it may not always perfectly mimic the behavior of the live DynamoDB service. In cases like this where you encounter inconsistencies, it's best to rely on the behavior of the live service as the correct implementation.
If you're developing an application that depends on this behavior, you should consider testing critical queries against the live DynamoDB service to ensure correct functionality. You may also want to report this issue to AWS support or through the AWS forums to bring it to their attention for potential fixes in future versions of DynamoDB Local.
Sources
ExecuteStatement - Amazon DynamoDB
PartiQL select statements for DynamoDB - Amazon DynamoDB
Relevant content
- AWS OFFICIALUpdated 2 years ago
