Method: Aws::DynamoDB::Client#batch_execute_statement

Defined in:
lib/aws-sdk-dynamodb/client.rb

#batch_execute_statement(params = {}) ⇒ Types::BatchExecuteStatementOutput

This operation allows you to perform batch reads or writes on data stored in DynamoDB, using PartiQL. Each read statement in a BatchExecuteStatement must specify an equality condition on all key attributes. This enforces that each SELECT statement in a batch returns at most a single item. For more information, see [Running batch operations with PartiQL for DynamoDB ][1].

<note markdown=“1”> The entire batch must consist of either read statements or write statements, you cannot mix both in one batch.

</note>

A HTTP 200 response does not mean that all statements in the BatchExecuteStatement succeeded. Error details for individual statements can be found under the [Error] field of the BatchStatementResponse for each statement.

[1]: docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.multiplestatements.batching.html [2]: docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchStatementResponse.html#DDB-Type-BatchStatementResponse-Error

Examples:

Request syntax with placeholder values


resp = client.batch_execute_statement({
  statements: [ # required
    {
      statement: "PartiQLStatement", # required
      parameters: ["value"], # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
      consistent_read: false,
      return_values_on_condition_check_failure: "ALL_OLD", # accepts ALL_OLD, NONE
    },
  ],
  return_consumed_capacity: "INDEXES", # accepts INDEXES, TOTAL, NONE
})

Response structure


resp.responses #=> Array
resp.responses[0].error.code #=> String, one of "ConditionalCheckFailed", "ItemCollectionSizeLimitExceeded", "RequestLimitExceeded", "ValidationError", "ProvisionedThroughputExceeded", "TransactionConflict", "ThrottlingError", "InternalServerError", "ResourceNotFound", "AccessDenied", "DuplicateItem"
resp.responses[0].error.message #=> String
resp.responses[0].error.item #=> Hash
resp.responses[0].error.item["AttributeName"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.responses[0].table_name #=> String
resp.responses[0].item #=> Hash
resp.responses[0].item["AttributeName"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.consumed_capacity #=> Array
resp.consumed_capacity[0].table_name #=> String
resp.consumed_capacity[0].capacity_units #=> Float
resp.consumed_capacity[0].read_capacity_units #=> Float
resp.consumed_capacity[0].write_capacity_units #=> Float
resp.consumed_capacity[0].table.read_capacity_units #=> Float
resp.consumed_capacity[0].table.write_capacity_units #=> Float
resp.consumed_capacity[0].table.capacity_units #=> Float
resp.consumed_capacity[0].local_secondary_indexes #=> Hash
resp.consumed_capacity[0].local_secondary_indexes["IndexName"].read_capacity_units #=> Float
resp.consumed_capacity[0].local_secondary_indexes["IndexName"].write_capacity_units #=> Float
resp.consumed_capacity[0].local_secondary_indexes["IndexName"].capacity_units #=> Float
resp.consumed_capacity[0].global_secondary_indexes #=> Hash
resp.consumed_capacity[0].global_secondary_indexes["IndexName"].read_capacity_units #=> Float
resp.consumed_capacity[0].global_secondary_indexes["IndexName"].write_capacity_units #=> Float
resp.consumed_capacity[0].global_secondary_indexes["IndexName"].capacity_units #=> Float

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :statements (required, Array<Types::BatchStatementRequest>)

    The list of PartiQL statements representing the batch to run.

  • :return_consumed_capacity (String)

    Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:

    • INDEXES - The response includes the aggregate ConsumedCapacity for the operation, together with ConsumedCapacity for each table and secondary index that was accessed.

      Note that some operations, such as GetItem and BatchGetItem, do not access any indexes at all. In these cases, specifying INDEXES will only return ConsumedCapacity information for table(s).

    • TOTAL - The response includes only the aggregate ConsumedCapacity for the operation.

    • NONE - No ConsumedCapacity details are included in the response.

Returns:

See Also:



609
610
611
612
# File 'lib/aws-sdk-dynamodb/client.rb', line 609

def batch_execute_statement(params = {}, options = {})
  req = build_request(:batch_execute_statement, params)
  req.send_request(options)
end