StartQueryExecution
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 AWS SDK for Java, see Examples and
Code Samples in the Amazon Athena User
Guide.
Request Syntax
{
"ClientRequestToken": "string
",
"ExecutionParameters": [ "string
" ],
"QueryExecutionContext": {
"Catalog": "string
",
"Database": "string
"
},
"QueryString": "string
",
"ResultConfiguration": {
"AclConfiguration": {
"S3AclOption": "string
"
},
"EncryptionConfiguration": {
"EncryptionOption": "string
",
"KmsKey": "string
"
},
"ExpectedBucketOwner": "string
",
"OutputLocation": "string
"
},
"ResultReuseConfiguration": {
"ResultReuseByAgeConfiguration": {
"Enabled": boolean
,
"MaxAgeInMinutes": number
}
},
"WorkGroup": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- 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 asQueryString
, has changed. A call toStartQueryExecution
that uses a previous client request token returns the sameQueryExecutionId
even if the requester doesn't have permission on the tables specified inQueryString
.Important
This token is listed as not required because AWS SDKs (for example the AWS SDK for Java) auto-generate the token for users. If you are not using the AWS SDK or the AWS CLI, you must provide this token or the action will fail.
Type: String
Length Constraints: Minimum length of 32. Maximum length of 128.
Required: No
- 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.
Type: Array of strings
Array Members: Minimum number of 1 item.
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- QueryExecutionContext
-
The database within which the query executes.
Type: QueryExecutionContext object
Required: No
- QueryString
-
The SQL query statements to be executed.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 262144.
Required: Yes
- 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.
Type: ResultConfiguration object
Required: No
- ResultReuseConfiguration
-
Specifies the query result reuse behavior for the query.
Type: ResultReuseConfiguration object
Required: No
- WorkGroup
-
The name of the workgroup in which the query is being started.
Type: String
Pattern:
[a-zA-Z0-9._-]{1,128}
Required: No
Response Syntax
{
"QueryExecutionId": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- QueryExecutionId
-
The unique ID of the query that ran as a result of this request.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
\S+
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalServerException
-
Indicates a platform issue, which may be due to a transient condition or outage.
HTTP Status Code: 500
- InvalidRequestException
-
Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.
HTTP Status Code: 400
- TooManyRequestsException
-
Indicates that the request was throttled.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: