Step Function - dynamodb query with Boolean Filter

0

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
3개 답변
2
수락된 답변

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

AWS
wongada
답변함 2년 전
1

According to this, you should change ":scheduled": { "BOOL":true } to ":scheduled": true Did not try it.

profile pictureAWS
전문가
Uri
답변함 2년 전
  • 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:

    There are Amazon States Language errors in your state machine definition. Fix the errors to continue.
    Cannot construct instance of `software.amazon.awssdk.services.dynamodb.model.AttributeValue$BuilderImpl` (although at least one Creator exists): no boolean/Boolean-argument constructor/factory method to deserialize from boolean value (true)
    For more information, see
    

    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
-1

Querying is not supported in SFN, just get, put, delete, and update.

답변함 2년 전
  • Query is supported by StepFunctions.

  • oops i was looking at optimized integrations. sorry!

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

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

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