Step Function - dynamodb query with Boolean Filter
Using Step function AWS SDK integration for querying dynamodb table with key condition and filter condition, below is the query works fine outside of step-function. When trying to save the state machine after adding this, get the below Error.
Ddb Query
{
"TableName": "test",
"ScanIndexForward": true,
"KeyConditionExpression": "pk = :pk",
"FilterExpression":"scheduled = :scheduled",
"ExpressionAttributeValues": {
":pk": {
"S": "test"
},
":scheduled": {
"BOOL":true
}
}
}
Error Saving State Machine
There are Amazon States Language errors in your state machine definition. Fix the errors to continue.
The field "BOOL" is not supported by Step Functions
For more information, see Amazon States Language
The optimized service integrations accept BOOL, however there is a difference between how AWS SDK integrations handle request parameters. If you switch from "BOOL"
to "Bool"
it will work. All parameters for AWS SDK integrations must be in PascalCase.
Source:
The API action will always be camel case, and parameter names will be Pascal case. For example, you could use Step Functions' startSyncExecution API action and specify the parameter StateMachineArn.
https://docs.aws.amazon.com/step-functions/latest/dg/supported-services-awssdk.html
According to this, you should change
":scheduled": {
"BOOL":true
}
to
":scheduled": true
Did not try it.
Querying is not supported in SFN, just get, put, delete, and update.
Query is supported by StepFunctions.
oops i was looking at optimized integrations. sorry!
Relevant questions
What is the impact of swapping CMKs that encrypt a DDB table?
Accepted Answerasked 2 years agoaws step functions dynamodb service integration & updating dynamic items
Accepted Answerasked 5 months agoRowCount for DynamoDB
Accepted Answerasked 3 years agoStep Function - dynamodb query with Boolean Filter
Accepted Answerasked 4 months agoDynamoDB local GSI KeyConditionExpression difference from live Dynamo
asked a year agoAre there any cases lead to "Query condition missed key schema element : sort key" ?
asked 3 months agoNow DynamoDB can return the throughput capacity consumed by PartiQL API calls to help you optimize your queries and throughput costs
asked 4 months agoCannot filter using the isValidIp function in CloudWatch
asked a month agoDynamoDB - Is it possible to query with a filter without data types?
Accepted Answerasked 2 years agoStep Function error handling
asked 2 months ago
Thanks for your suggestion. But unfortunately this doesn't work as its javascript. Looks like internally the step-function uses JAVA SDK. Was able to figure this out from the error:
Here is the Java doc for Filter Expression. Its like chicken and egg situation here: 1. Java sdk for dynamodb accepts only a map of <String, AttributeValue> ({"pk":{"S":"data"}, "scheduled":{"BOOL":true}} 2. in State Language "BOOL" is a reserved keyword probably and not being accepted