airflow.providers.amazon.aws.hooks.athena
¶
This module contains AWS Athena hook.
Module Contents¶
Classes¶
Interact with Amazon Athena. |
- class airflow.providers.amazon.aws.hooks.athena.AthenaHook(*args, sleep_time=30, log_query=True, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook
Interact with Amazon Athena.
Provide thick wrapper around
boto3.client("athena")
.- Parameters
Additional arguments (such as
aws_conn_id
) may be specified and are passed down to the underlying AwsBaseHook.- run_query(query, query_context, result_configuration, client_request_token=None, workgroup='primary')[source]¶
Run a Presto query on Athena with provided config.
- Parameters
query (str) – Presto query to run.
query_context (dict[str, str]) – Context in which query need to be run.
result_configuration (dict[str, Any]) – Dict with path to store results in and config related to encryption.
client_request_token (str | None) – Unique token created by user to avoid multiple executions of same query.
workgroup (str) – Athena workgroup name, when not specified, will be
'primary'
.
- Returns
Submitted query execution ID.
- Return type
- get_state_change_reason(query_execution_id)[source]¶
Fetch the reason for a state change (e.g. error message). Returns None or reason string.
See also
- Parameters
query_execution_id (str) – Id of submitted athena query
- get_query_results(query_execution_id, next_token_id=None, max_results=1000)[source]¶
Fetch submitted query results.
See also
- Parameters
- Returns
None if the query is in intermediate, failed, or cancelled state. Otherwise a dict of query outputs.
- Return type
dict | None
- get_query_results_paginator(query_execution_id, max_items=None, page_size=None, starting_token=None)[source]¶
Fetch submitted Athena query results.
See also
- Parameters
- Returns
None if the query is in intermediate, failed, or cancelled state. Otherwise a paginator to iterate through pages of results.
- Return type
botocore.paginate.PageIterator | None
Call :meth`.build_full_result()` on the returned paginator to get all results at once.
- poll_query_status(query_execution_id, max_polling_attempts=None)[source]¶
Poll the state of a submitted query until it reaches final state.
- get_output_location(query_execution_id)[source]¶
Get the output location of the query results in S3 URI format.
See also
- Parameters
query_execution_id (str) – Id of submitted athena query