Amazon Athena Operators

Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon Simple Storage Service (S3) using standard SQL. Athena is serverless, so there is no infrastructure to setup or manage, and you pay only for the queries you run. To get started, simply point to your data in S3, define the schema, and start querying using standard SQL.

Prerequisite Tasks

To use these operators, you must do a few things:

Athena Operator

Use the AthenaOperator to run a query in Amazon Athena.

In the following example, we query an existing Athena table and send the results to an existing Amazon S3 bucket. For more examples of how to use this operator, please see the Sample DAG.

airflow/providers/amazon/aws/example_dags/example_athena.py[source]

read_table = AthenaOperator(
    task_id='read_table',
    query=QUERY_READ_TABLE,
    database=ATHENA_DATABASE,
    output_location=f's3://{S3_BUCKET}/{S3_KEY}',
)

Athena Sensor

Use the AthenaSensor to wait for the results of a query in Amazon Athena.

airflow/providers/amazon/aws/example_dags/example_athena.py[source]

await_query = AthenaSensor(
    task_id='await_query',
    query_execution_id=read_table.output,
)

Reference

For further information, look at:

Was this entry helpful?