startQueryExecution method
Runs the SQL query statements contained in the Query.
Requires you to have access to the workgroup in which the query ran.
Running queries against an external catalog requires GetDataCatalog
permission to the catalog. For code samples using the Amazon Web Services
SDK for Java, see Examples
and Code Samples in the Amazon Athena User Guide.
May throw InternalServerException.
May throw InvalidRequestException.
May throw TooManyRequestsException.
Parameter queryString :
The SQL query statements to be executed.
Parameter clientRequestToken :
A unique case-sensitive string used to ensure the request to create the
query is idempotent (executes only once). If another
StartQueryExecution request is received, the same response is
returned and another query is not created. An error is returned if a
parameter, such as QueryString, has changed. A call to
StartQueryExecution that uses a previous client request token
returns the same QueryExecutionId even if the requester
doesn't have permission on the tables specified in
QueryString.
Parameter engineConfiguration :
The engine configuration for the workgroup, which includes the
minimum/maximum number of Data Processing Units (DPU) that queries should
use when running in provisioned capacity. If not specified, Athena uses
default values (Default value for min is 4 and for max is Minimum of 124
and allocated DPUs).
To specify minimum and maximum DPU values for Capacity Reservations
queries, the workgroup containing EngineConfiguration should
have the following values: The name of the Classifications
should be athena-query-engine-properties, with the only
allowed properties as max-dpu-count and
min-dpu-count.
Parameter executionParameters :
A list of values for the parameters in a query. The values are applied
sequentially to the parameters in the query in the order in which the
parameters occur.
Parameter queryExecutionContext :
The database within which the query executes.
Parameter resultConfiguration :
Specifies information about where and how to save the results of the query
execution. If the query runs in a workgroup, then workgroup's settings may
override query settings. This affects the query results location. The
workgroup settings override is specified in EnforceWorkGroupConfiguration
(true/false) in the WorkGroupConfiguration. See
WorkGroupConfiguration$EnforceWorkGroupConfiguration.
Parameter resultReuseConfiguration :
Specifies the query result reuse behavior for the query.
Parameter workGroup :
The name of the workgroup in which the query is being started.
Implementation
Future<StartQueryExecutionOutput> startQueryExecution({
required String queryString,
String? clientRequestToken,
EngineConfiguration? engineConfiguration,
List<String>? executionParameters,
QueryExecutionContext? queryExecutionContext,
ResultConfiguration? resultConfiguration,
ResultReuseConfiguration? resultReuseConfiguration,
String? workGroup,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonAthena.StartQueryExecution'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'QueryString': queryString,
'ClientRequestToken':
clientRequestToken ?? _s.generateIdempotencyToken(),
if (engineConfiguration != null)
'EngineConfiguration': engineConfiguration,
if (executionParameters != null)
'ExecutionParameters': executionParameters,
if (queryExecutionContext != null)
'QueryExecutionContext': queryExecutionContext,
if (resultConfiguration != null)
'ResultConfiguration': resultConfiguration,
if (resultReuseConfiguration != null)
'ResultReuseConfiguration': resultReuseConfiguration,
if (workGroup != null) 'WorkGroup': workGroup,
},
);
return StartQueryExecutionOutput.fromJson(jsonResponse.body);
}