Questions tagged [dynamodb-queries]

Use when content is about querying or scanning Amazon DynamoDB managed database.

1232 questions
7
votes
2 answers

DynamoDB how to use index in PartiQL queries?

I have seen the dynamoDB doc for the PartiQL syntax: SELECT expression [, ...] FROM table[.index] [ WHERE condition ] [ [ORDER BY key [DESC|ASC] , ...] but in practice: select * from dev .pk-all-index where "pk" = 'config' AND ("brand" = 'tesla'…
fred_
  • 1,486
  • 1
  • 19
  • 31
7
votes
2 answers

Is it possible to run a greater than query in AWS DynamoDB?

Let's say I have my DynamoDB table like this, with Order ID as the primary key. : The Order ID increments by one, everytime I add/put a new item. Now, I have one number, let's say 1000, and my user wants to get all the items which have Order ID >…
kartik
  • 550
  • 1
  • 6
  • 19
7
votes
1 answer

DynamoDB - Sort key attribute name

When creating a composite key in DynamoDB with a hash and range/sort key, it seems really useful to store creative string values in the sort key (e.g. “Details-123456-foo”, where each segment in that value can be something meaningful for that…
tbehunin
  • 1,043
  • 1
  • 12
  • 24
7
votes
1 answer

DynamoDb: Query items between two dates

I'm not having much luck with this query, it returns 0 items const { Items } = await this.dynamoDb.query({ TableName: 'exampleTableName', IndexName: 'createdDateTime-index', KeyConditionExpression: '#createdDateTime BETWEEN :fromDateTime AND…
ChrisRich
  • 8,300
  • 11
  • 48
  • 67
7
votes
3 answers

DynamoDB w/ Serverless, using Fn::GetRef to reference global secondary index

I have an API/service I'm defining with a DynamoDB table. I have a couple indexes (defined as Global Secondary Index) to support a couple queries. I have the table designed, with the GSI definitions, and what looks like correct queries. However,…
7
votes
1 answer

DynamoDB queries on secondary index, how to define the indexes

I've been going around and around this and it's just not clear what to do. I have a simple table where I want to make queries against several columns. As I understand it, that means creating a secondary index for each column there is to query…
6
votes
0 answers

Using AWS DynamoDBDocumentClient for Marshall/Unmarshall Complex Objects Throws an Error

I'm using AWS SDK (v3) in my NodeJS/Typescript application, specifically their DynamoDBDocumentClient to easily marshall/unmarshall my entities to reduce the amount of code needed to query the database. As my entities are complex objects, meaning…
6
votes
1 answer

NUMBER_VALUE cannot be converted to String when updating Item

I have this strange issue with DynamoDB where I cannot seem to update an item. Here is my command: TableName: 'UserTable', Key: { UID: { S: 'h4XJj3YRxZiF7TDcGkxAhc' } }, UpdateExpression: 'SET numRatings = :numRatings', ExpressionAttributeValues: {…
6
votes
1 answer

With DynamoDb enhanced client from java aws sdk, how do you query using a compound keyConditionExpression?

I have a DynamoDb table with a GSI over two keys - string field 'id' (partition key) and number field 'count' (sort key). I'm trying to work out how to run a query (not scan) via a Spring Java application using the DynamoDbEnhancedClient in the SDK…
6
votes
1 answer

How do I query by only part of a composite key in DynamoDB?

Let's say, I have Users writing reviews of Products. User and Product are separate entities with their own ids. Review is an entity with a composite id composed of userId and productId. I have created a table review in DynamoDB with both userId and…
Vihung
  • 12,947
  • 16
  • 64
  • 90
6
votes
1 answer

DynamoDB update fails when nested path not exists

My table structure is below where time is the unique key and that "01" was the id of the count, the item of a month will create right after any id get the count result of that month. { "details": { "01": { "a": { "count": [10,…
6
votes
1 answer

Limit method in QueryEnhancedRequest for DynamoDB Java v2 sdk doesn't limit as expected

I'm using the v2 aws DynamoDV Java sdk, and I want to limit the number of results that are returned when querying by the partition key (code snippet below), but the code below returns the full set of items back. The java docs say "Note:The limit…
6
votes
2 answers

How does AWS DynamoDB count read units for Query?

I am working on a table, in which every item is approx. 3KB in size. Now as per the docs, the read units are calculated in 4s - i.e. For every item less than 4 kb, it would be counted as 4KB, and occupy 1 read unit. Let's say i have a table of 100…
kartik
  • 550
  • 1
  • 6
  • 19
6
votes
1 answer

Pagination with Filtering using Query Operation in DynamoDB Template

I would like to be able to filter a pagination result using query operation before the limit is taken into consideration.Is there any suggestion to get right pagination on filtered results? I would like to implement a DynamoDB Scan OR Query with the…
Taha Farooqui
  • 637
  • 10
  • 25
6
votes
2 answers

DynamoDb: How to retrieve the first item (by sort key) for each of a given list of partition keys

I have a dynamodb table that stores historical run data for processes that run on my server, I need a place where I can aggregate these processes and see the data for the latest of each of these. Each process has it's own ProcessId which is the…
1
2
3
82 83