executeStatement method
This operation allows you to perform reads and singleton writes on data stored in DynamoDB, using PartiQL.
For PartiQL reads (SELECT statement), if the total number of
processed items exceeds the maximum dataset size limit of 1 MB, the read
stops and results are returned to the user as a
LastEvaluatedKey value to continue the read in a subsequent
operation. If the filter criteria in WHERE clause does not
match any data, the read will return an empty result set.
A single SELECT statement response can return up to the
maximum number of items (if using the Limit parameter) or a maximum of 1
MB of data (and then apply any filtering to the results using
WHERE clause). If LastEvaluatedKey is present in
the response, you need to paginate the result set. If
NextToken is present, you need to paginate the result set and
include NextToken.
May throw ConditionalCheckFailedException.
May throw DuplicateItemException.
May throw InternalServerError.
May throw ItemCollectionSizeLimitExceededException.
May throw ProvisionedThroughputExceededException.
May throw RequestLimitExceeded.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw TransactionConflictException.
Parameter statement :
The PartiQL statement representing the operation to run.
Parameter consistentRead :
The consistency of a read operation. If set to true, then a
strongly consistent read is used; otherwise, an eventually consistent read
is used.
Parameter limit :
The maximum number of items to evaluate (not necessarily the number of
matching items). If DynamoDB processes the number of items up to the limit
while processing the results, it stops the operation and returns the
matching values up to that point, along with a key in
LastEvaluatedKey to apply in a subsequent operation so you
can pick up where you left off. Also, if the processed dataset size
exceeds 1 MB before DynamoDB reaches this limit, it stops the operation
and returns the matching values up to the limit, and a key in
LastEvaluatedKey to apply in a subsequent operation to
continue the operation.
Parameter nextToken :
Set this value to get remaining results, if NextToken was
returned in the statement response.
Parameter parameters :
The parameters for the PartiQL statement, if any.
Parameter returnValuesOnConditionCheckFailure :
An optional parameter that returns the item attributes for an
ExecuteStatement operation that failed a condition check.
There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.
Implementation
Future<ExecuteStatementOutput> executeStatement({
required String statement,
bool? consistentRead,
int? limit,
String? nextToken,
List<AttributeValue>? parameters,
ReturnConsumedCapacity? returnConsumedCapacity,
ReturnValuesOnConditionCheckFailure? returnValuesOnConditionCheckFailure,
}) async {
_s.validateNumRange(
'limit',
limit,
1,
1152921504606846976,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'DynamoDB_20120810.ExecuteStatement'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Statement': statement,
if (consistentRead != null) 'ConsistentRead': consistentRead,
if (limit != null) 'Limit': limit,
if (nextToken != null) 'NextToken': nextToken,
if (parameters != null) 'Parameters': parameters,
if (returnConsumedCapacity != null)
'ReturnConsumedCapacity': returnConsumedCapacity.value,
if (returnValuesOnConditionCheckFailure != null)
'ReturnValuesOnConditionCheckFailure':
returnValuesOnConditionCheckFailure.value,
},
);
return ExecuteStatementOutput.fromJson(jsonResponse.body);
}