airflow.contrib.hooks.aws_athena_hook
¶
This module contains AWS Athena hook
Module Contents¶
-
class
airflow.contrib.hooks.aws_athena_hook.
AWSAthenaHook
(aws_conn_id='aws_default', sleep_time=30, *args, **kwargs)[source]¶ Bases:
airflow.contrib.hooks.aws_hook.AwsHook
Interact with AWS Athena to run, poll queries and return query results
- Parameters
-
get_conn
(self)[source]¶ check if aws conn exists already or create one and return it
- Returns
boto3 session
-
run_query
(self, query, query_context, result_configuration, client_request_token=None)[source]¶ Run Presto query on athena with provided config and return submitted query_execution_id
- Parameters
- Returns
str
-
check_query_status
(self, query_execution_id)[source]¶ Fetch the status of submitted athena query. Returns None or one of valid query states.
- Parameters
query_execution_id (str) – Id of submitted athena query
- Returns
str
-
get_state_change_reason
(self, query_execution_id)[source]¶ Fetch the reason for a state change (e.g. error message). Returns None or reason string.
- Parameters
query_execution_id (str) – Id of submitted athena query
- Returns
str
-
get_query_results
(self, query_execution_id)[source]¶ Fetch submitted athena query results. returns none if query is in intermediate state or failed/cancelled state else dict of query output
- Parameters
query_execution_id (str) – Id of submitted athena query
- Returns
dict