Amazon Redshift SQL¶
Amazon Redshift manages all the work of setting up, operating, and scaling a data warehouse: provisioning capacity, monitoring and backing up the cluster, and applying patches and upgrades to the Amazon Redshift engine. You can focus on using your data to acquire new insights for your business and customers.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AWS Console or AWS CLI.
Install API libraries via pip.
pip install 'apache-airflow[amazon]'Detailed information is available Installation of Airflow™
Operators¶
Execute a SQL query¶
The generic SQLExecuteQueryOperator
can be used to execute SQL queries against an Amazon Redshift cluster using a Redshift connection.
To execute a SQL query against an Amazon Redshift cluster without using a Redshift connection,
please check RedshiftDataOperator
.
tests/system/providers/common/sql/example_sql_execute_query.py
execute_query = SQLExecuteQueryOperator(
task_id="execute_query",
sql=f"SELECT 1; SELECT * FROM {AIRFLOW_DB_METADATA_TABLE} LIMIT 1;",
split_statements=True,
return_last=False,
)