Skip to content

aws.athena.get_query_execution

Example SQL Queries

SELECT * FROM
aws.athena.get_query_execution
WHERE
"query_execution_id" = 'VALUE';

Description

Returns information about a single execution of a query if you have access to the workgroup in which the query ran. Each time a query executes, information about the query execution is saved with a unique ID.

Table Definition

Column NameColumn Data Type
query_execution_id Required Input Column

The unique ID of the query execution.

VARCHAR
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

_aws_region Input Column

The AWS region to use.

VARCHAR
query_execution

Information about the query execution.

STRUCT(
"query_execution_id" VARCHAR,
"query" VARCHAR,
"statement_type" VARCHAR,
"result_configuration" STRUCT(
"output_location" VARCHAR,
"encryption_configuration" STRUCT(
"encryption_option" VARCHAR,
"kms_key" VARCHAR
),
"expected_bucket_owner" VARCHAR,
"acl_configuration" STRUCT(
"s3_acl_option" VARCHAR
)
),
"result_reuse_configuration" STRUCT(
"result_reuse_by_age_configuration" STRUCT(
"enabled" BOOLEAN,
"max_age_in_minutes" BIGINT
)
),
"query_execution_context" STRUCT(
"database" VARCHAR,
"catalog" VARCHAR
),
"status" STRUCT(
"state" VARCHAR,
"state_change_reason" VARCHAR,
"submission_date_time" TIMESTAMP_S,
"completion_date_time" TIMESTAMP_S,
"athena_error" STRUCT(
"error_category" BIGINT,
"error_type" BIGINT,
"retryable" BOOLEAN,
"error_message" VARCHAR
)
),
"statistics" STRUCT(
"engine_execution_time_in_millis" BIGINT,
"data_scanned_in_bytes" BIGINT,
"data_manifest_location" VARCHAR,
"total_execution_time_in_millis" BIGINT,
"query_queue_time_in_millis" BIGINT,
"service_pre_processing_time_in_millis" BIGINT,
"query_planning_time_in_millis" BIGINT,
"service_processing_time_in_millis" BIGINT,
"result_reuse_information" STRUCT(
"reused_previous_result" BOOLEAN
)
),
"work_group" VARCHAR,
"engine_version" STRUCT(
"selected_engine_version" VARCHAR,
"effective_engine_version" VARCHAR
),
"execution_parameters" VARCHAR[],
"substatement_type" VARCHAR,
"query_results_s3_access_grants_configuration" STRUCT(
"enable_s3_access_grants" BOOLEAN,
"create_user_level_prefix" BOOLEAN,
"authentication_type" VARCHAR
)
)
Show child fields
query_execution.engine_version

The engine version that executed the query.

Show child fields
query_execution.engine_version.effective_engine_version

Read only. The engine version on which the query runs. If the user requests a valid engine version other than Auto, the effective engine version is the same as the engine version that the user requested. If the user requests Auto, the effective engine version is chosen by Athena. When a request to update the engine version is made by a CreateWorkGroup or UpdateWorkGroup operation, the EffectiveEngineVersion field is ignored.

query_execution.engine_version.selected_engine_version

The engine version requested by the user. Possible values are determined by the output of ListEngineVersions, including AUTO. The default is AUTO.

query_execution.execution_parameters[]
query_execution.query

The SQL query statements which the query execution ran.

query_execution.query_execution_context

The database in which the query execution occurred.

Show child fields
query_execution.query_execution_context.catalog

The name of the data catalog used in the query execution.

query_execution.query_execution_context.database

The name of the database used in the query execution. The database must exist in the catalog.

query_execution.query_execution_id

The unique identifier for each query execution.

query_execution.query_results_s3_access_grants_configuration

Specifies whether Amazon S3 access grants are enabled for query results.

Show child fields
query_execution.query_results_s3_access_grants_configuration.authentication_type

The authentication type used for Amazon S3 access grants. Currently, only DIRECTORY_IDENTITY is supported.

query_execution.query_results_s3_access_grants_configuration.create_user_level_prefix

When enabled, appends the user ID as an Amazon S3 path prefix to the query result output location.

query_execution.query_results_s3_access_grants_configuration.enable_s3_access_grants

Specifies whether Amazon S3 access grants are enabled for query results.

query_execution.result_configuration

The location in Amazon S3 where query and calculation results are stored and the encryption option, if any, used for query results. These are known as "client-side settings". If workgroup settings override client-side settings, then the query uses the location for the query results and the encryption configuration that are specified for the workgroup.

Show child fields
query_execution.result_configuration.acl_configuration

Indicates that an Amazon S3 canned ACL should be set to control ownership of stored query results. Currently the only supported canned ACL is BUCKET_OWNER_FULL_CONTROL. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the ACL configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. For more information, see WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings.

Show child fields
query_execution.result_configuration.acl_configuration.s3_acl_option

The Amazon S3 canned ACL that Athena should specify when storing query results. Currently the only supported canned ACL is BUCKET_OWNER_FULL_CONTROL. If a query runs in a workgroup and the workgroup overrides client-side settings, then the Amazon S3 canned ACL specified in the workgroup's settings is used for all queries that run in the workgroup. For more information about Amazon S3 canned ACLs, see Canned ACL in the Amazon S3 User Guide.

query_execution.result_configuration.encryption_configuration

If query and calculation results are encrypted in Amazon S3, indicates the encryption option used (for example, SSE_KMS or CSE_KMS) and key information. This is a client-side setting. If workgroup settings override client-side settings, then the query uses the encryption configuration that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings.

Show child fields
query_execution.result_configuration.encryption_configuration.encryption_option

Indicates whether Amazon S3 server-side encryption with Amazon S3-managed keys (SSE_S3), server-side encryption with KMS-managed keys (SSE_KMS), or client-side encryption with KMS-managed keys (CSE_KMS) is used.

If a query runs in a workgroup and the workgroup overrides client-side settings, then the workgroup's setting for encryption is used. It specifies whether query results must be encrypted, for all queries that run in this workgroup.

query_execution.result_configuration.encryption_configuration.kms_key

For SSE_KMS and CSE_KMS, this is the KMS key ARN or ID.

query_execution.result_configuration.expected_bucket_owner

The Amazon Web Services account ID that you expect to be the owner of the Amazon S3 bucket specified by ResultConfiguration$OutputLocation. If set, Athena uses the value for ExpectedBucketOwner when it makes Amazon S3 calls to your specified output location. If the ExpectedBucketOwner Amazon Web Services account ID does not match the actual owner of the Amazon S3 bucket, the call fails with a permissions error.

This is a client-side setting. If workgroup settings override client-side settings, then the query uses the ExpectedBucketOwner setting that is specified for the workgroup, and also uses the location for storing query results specified in the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration and Workgroup Settings Override Client-Side Settings.

query_execution.result_configuration.output_location

The location in Amazon S3 where your query and calculation results are stored, such as s3://path/to/query/bucket/. To run the query, you must specify the query results location using one of the ways: either for individual queries using either this setting (client-side), or in the workgroup, using WorkGroupConfiguration. If none of them is set, Athena issues an error that no output location is provided. If workgroup settings override client-side settings, then the query uses the settings specified for the workgroup. See WorkGroupConfiguration$EnforceWorkGroupConfiguration.

query_execution.result_reuse_configuration

Specifies the query result reuse behavior that was used for the query.

Show child fields
query_execution.result_reuse_configuration.result_reuse_by_age_configuration

Specifies whether previous query results are reused, and if so, their maximum age.

Show child fields
query_execution.result_reuse_configuration.result_reuse_by_age_configuration.enabled

True if previous query results can be reused when the query is run; otherwise, false. The default is false.

query_execution.result_reuse_configuration.result_reuse_by_age_configuration.max_age_in_minutes

Specifies, in minutes, the maximum age of a previous query result that Athena should consider for reuse. The default is 60.

query_execution.statement_type

The type of query statement that was run. DDL indicates DDL query statements. DML indicates DML (Data Manipulation Language) query statements, such as CREATE TABLE AS SELECT. UTILITY indicates query statements other than DDL and DML, such as SHOW CREATE TABLE, or DESCRIBE TABLE.

query_execution.statistics

Query execution statistics, such as the amount of data scanned, the amount of time that the query took to process, and the type of statement that was run.

Show child fields
query_execution.statistics.data_manifest_location

The location and file name of a data manifest file. The manifest file is saved to the Athena query results location in Amazon S3. The manifest file tracks files that the query wrote to Amazon S3. If the query fails, the manifest file also tracks files that the query intended to write. The manifest is useful for identifying orphaned files resulting from a failed query. For more information, see Working with Query Results, Output Files, and Query History in the Amazon Athena User Guide.

query_execution.statistics.data_scanned_in_bytes

The number of bytes in the data that was queried.

query_execution.statistics.engine_execution_time_in_millis

The number of milliseconds that the query took to execute.

query_execution.statistics.query_planning_time_in_millis

The number of milliseconds that Athena took to plan the query processing flow. This includes the time spent retrieving table partitions from the data source. Note that because the query engine performs the query planning, query planning time is a subset of engine processing time.

query_execution.statistics.query_queue_time_in_millis

The number of milliseconds that the query was in your query queue waiting for resources. Note that if transient errors occur, Athena might automatically add the query back to the queue.

query_execution.statistics.result_reuse_information

Contains information about whether previous query results were reused for the query.

Show child fields
query_execution.statistics.result_reuse_information.reused_previous_result

True if a previous query result was reused; false if the result was generated from a new run of the query.

query_execution.statistics.service_pre_processing_time_in_millis

The number of milliseconds that Athena took to preprocess the query before submitting the query to the query engine.

query_execution.statistics.service_processing_time_in_millis

The number of milliseconds that Athena took to finalize and publish the query results after the query engine finished running the query.

query_execution.statistics.total_execution_time_in_millis

The number of milliseconds that Athena took to run the query.

query_execution.status

The completion date, current state, submission time, and state change reason (if applicable) for the query execution.

Show child fields
query_execution.status.athena_error

Provides information about an Athena query error.

Show child fields
query_execution.status.athena_error.error_category

An integer value that specifies the category of a query failure error. The following list shows the category for each integer value.

1 - System

2 - User

3 - Other

query_execution.status.athena_error.error_message

Contains a short description of the error that occurred.

query_execution.status.athena_error.error_type

An integer value that provides specific information about an Athena query error. For the meaning of specific values, see the Error Type Reference in the Amazon Athena User Guide.

query_execution.status.athena_error.retryable

True if the query might succeed if resubmitted.

query_execution.status.completion_date_time

The date and time that the query completed.

query_execution.status.state

The state of query execution. QUEUED indicates that the query has been submitted to the service, and Athena will execute the query as soon as resources are available. RUNNING indicates that the query is in execution phase. SUCCEEDED indicates that the query completed without errors. FAILED indicates that the query experienced an error and did not complete processing. CANCELLED indicates that a user input interrupted query execution.

Athena automatically retries your queries in cases of certain transient errors. As a result, you may see the query state transition from RUNNING or FAILED to QUEUED.

query_execution.status.state_change_reason

Further detail about the status of the query.

query_execution.status.submission_date_time

The date and time that the query was submitted.

query_execution.substatement_type

The kind of query statement that was run.

query_execution.work_group

The name of the workgroup in which the query ran.