Menu
Amazon Athena
Amazon Athena Documentation (API Version 2017-05-18)

StartQueryExecution

Runs (executes) the SQL query statements contained in the Query string.

For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon Athena User Guide.

Request Syntax

Copy
{ "ClientRequestToken": "string", "QueryExecutionContext": { "Database": "string" }, "QueryString": "string", "ResultConfiguration": { "EncryptionConfiguration": { "EncryptionOption": "string", "KmsKey": "string" }, "OutputLocation": "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. If a parameter has changed, for example, the QueryString, an error is returned.

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

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.

Type: ResultConfiguration object

Required: Yes

Response Syntax

Copy
{ "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

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: