DynamoDB Delete Table Item

This Snap deletes an item or a bunch of items (based on batch size) from an existing table in AWS DynamoDB.

Note: The delete operation performed by this Snap is Idempotent, that means even when the given input records do not exist, the Snap still gives an HTTP 200 response.

To select the items to delete with a query instead of a Delete condition, use a longer pipeline: DynamoDB Query → Mapper → DynamoDB Delete Table Item. In the Mapper Snap, map $yourPartitionKey to $Key.yourPartitionKey and $yourSortKey to $Key.yourSortKey.

Supported Accounts

Snap views

Type Description Examples of upstream and downstream Snaps
Input This Snap has exactly one document input view. The table's key schema is suggested on input view.
  • The input document must contain a Key object that identifies the item to delete.
  • Key must have the partition key, plus the sort key if the table has one. Without the full primary key, DynamoDB can't find the item.

Example:

{ "Key": { "PartitionKeyName": { "S": "value1" }, "SortKeyName": { "S": "value2" } } }
{ "Key": { "PartitionKeyName": { "S": "value1" } } }
Output This Snap has exactly one document output view. This Snap returns an HTTP response code 200 on success.
Learn more about Error handling.

Snap settings

Note: Learn about the common controls in the Snap settings dialog.
Field/Field set Description

Label

String
Specify a unique name for the Snap. Modify this to be more appropriate, especially if there are more than one of the same Snap in the pipeline.

Default value: DynamoDB Delete Table Item

Table name

String/Expression
Required. The name of the table to delete the data from. This property is suggestible, which shows the list of the tables in the database.

Default value: None

Example: Thread

Delete condition

String/Expression

Specify a logical condition to delete the item. This field is optional and does not pick the item to delete. It is a check that has to pass for the delete operation to succeed (for example, delete only if accountStatus = :status, with :status defined in Expression attribute values).

  • If this field is empty, the item named in Key is deleted with no condition.
  • If the condition is false, the Snap returns an error and doesn't delete the item.
Note:
  • Applicable only when Batch size is 1. Delete condition must be empty if Batch size is greater than one.
  • You can set this condition for deleting an item based on its non-key attributes, as well.

Default value: None

Example deletion scenarios:

  • A simple delete: Leave this field empty.
  • Delete item only if the attribute exists: attribute_exists(duplicate1)
  • Delete only if the status matches: accountStatus = :status, with :status of type S and value inactive in Expression attribute values.
  • Delete only if the version matches: itemVersion = :ver, with :ver of type N and value 36 in Expression attribute values.
  • Delete only if the record was created before 2000: CreatedDateTime < :cutoffDate, with :cutoffDate of type S and value 1999-12-31T23:59:59Z in Expression attribute values.

When to use each important field in this Snap:

Field Purpose Required?
Key (input document) Specify which item to delete Yes
Delete condition Specify when the item can be deleted No
Expression attribute values Specify values the condition refers to Only if the condition uses them
Batch size

Integer/Expression
Specifies the number of records to be deleted in a single request.

Default value: 1

Output deleted records

Checkbox
Specifies whether or not to display the original records in the output view.

Default value: Not selected

Expression attribute values

Specify the placeholders (:value or #name) that the Delete condition uses for the Expression Attribute Names and/or Expression Attribute Values.

Example:

  1. If your table contains a column named UUID (a reserved word) and you want to delete a value from the UUID column, then you must assign a placeholder for the column name because you cannot use a reserved word directly in your expression. You can define the Attribute #u, leave the Type blank, and enter the value as UUID. In the Snap Delete condition, enter #u=:val1.
    Expression attribute values example

  2. Suppose, you have a table T1 with a column named Product. We want to delete a value from the Product column. Here, you cannot enter Product=value in the delete condition directly. You must assign a placeholder for the value. Hence, define the Attribute :val1 of Type S and under Value, pass $values1. In the Snap Delete condition, we enter Product=:val1.
    Expression attribute values example

Note: DynamoDB reserves certain words and they are called reserved words. You must not use reserved words as attribute names in expressions. If you must write an expression that contains a word that conflicts with a DynamoDB reserved word, then you can define an expression attribute name to use in the place of the reserved word. For more information, see Expression Attribute Names. Similarly, you cannot use certain values as attribute values in expressions and instead must define an expression attribute name. For more information, see Expression Attribute Values.
Attribute

String/Expression
The expression attribute name. Begins with a # for names and : for values.

Default value: None

Example: :val1, #U

Type

String/Expression
The attribute type. Blank for Expression Attribute Names. B for binary, S for string, N for number, BOOL for Boolean, and so on, for values.

Default value: None

Example: B

Value

String/Expression
The actual literal to be used in the delete condition.

Default value: None

Example: 13, UUID, inactive

Snap execution

Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

DynamoDB Complex types

DynamoDB supports the following complex types:

Sets

String Set [SS]

A value of this type contains a set of strings delimited by double quotes as follows:

Pattern: [String object 1, String object 2, ........, String Object n]

Example: ["Snaplogic", "San Mateo", "Pipeline"]

Number Set [NS]

A value of this type contains a set of numbers delimited by double quotes as follows:

Pattern: [Number Obj1, Number Object2,...., Number Object n]

Example: ["123", "24.56", "-35", "-21.456","0"]

Binary Set [BS]

A value of this type contains a set of base64-encoded binary data objects delimited by double quotes as follows:

Pattern: [ Binary Object 1, Binary Object 2,...Binary Object n]

Example: ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]

List (L)

A value of this type contains a set of objects. Each object further can be of any type (String, Number, String Set, Map, List etc.,). In general, the List object resembles a JSON array.

Pattern: [ object 1, object 2, ........, Object n]

Example: [{"N":"3"},{"S":"-7.5"},{"B":"U3Vubnk="},{"L":[{"N":"-45.56"},{"M":{"Name":{"S":"ahmed"}}}]}, {"M":{"name":{"S":"syed"}}},{"SS":["a","b"]},{"BS":["U3Vubnk="]},{"NS":["23","45"]}]

Map (M)

A value of this type contains a set of key-value pairs. Keys are always strings, whereas values can be of any type (String, Number, String Set, Map, List etc.,). In general, the Map object resembles a JSON object.

Pattern: {"Key1":Object1, "Key2": Object2......"Keyn": Objectn}

Example: {"id":{"S":"snaplogic"}, "orgs":{"L":[{"S":"uat"}, {"S":"qa"}]}, "admins":{"L":[{"M":{"name":{"S":"a"}}}, {"M":{"name":{"S":"45"}}}]}}

The pipeline using the Binary Set types for the Delete Table Item Snap:


Pipeline using Binary Set types


Mapper key setting


DynamoDB Delete Table Item Snap configuration


Set types output preview

Troubleshooting

Error Reason Resolution
NullPointerException at DynamoDBCommon.getPrimaryKey There is a missing or incomplete Key in the input document.
  • The DynamoDB Delete Table Item Snap expects the primary key to be provided in the input document with a specific structure ({"Key": {"PartitionKey": {"S": "value"}}}), rather than being derived from the Delete condition field.
  • The Delete condition and Expression Attribute Values are not used to specify which item should be deleted. These fields are only used when a conditional delete is required.
Add a Mapper that builds the full Key structure. For example, in a pipeline that uses the DynamoDB Scan and DynamoDB Delete Table Item Snaps, add a Mapper Snap before the DynamoDB Delete Table Item Snap so that your primary key is in the correct structure. If your primary key is UserOkta and your Sort Key is CreatedDateTime, the Mapper Snap would have the following expressions:
Expression Target Path
$UserOkta $Key.UserOkta
$CreatedDateTime $Key.CreatedDateTime