如何使用 Airflow(版本 1)在 redshift 中执行 SQL
How to execute SQL in redshift with Airflow (version 1)
有没有办法从气流中触发红移存储过程?
最好的情况是不使用 python 运算符,但我还没有在 airflow 版本 < 2.
中找到 reshift 运算符
在 Airflow <2.1
中没有 RedShiftSqlOperator
因为 RedShift 与 PostgreSQL 兼容所以你可以只使用 PostgresOperator
:
from airflow.providers.postgres.operators.postgres import PostgresOperator
PostgresOperator(
sql='SELECT * FROM my_table',
postgres_conn_id='redshift_default',
task_id='task',
)
也就是说,在较新的版本 (Airflow >= 2.1
) 中,一些用户也在为这个问题苦苦挣扎(参见 GitHub issue) Airflow added RedshiftSQLOperator
which is available in Amazon provider 2.4.0 版:
pip install apache-airflow-providers-amazon>=2.4.0
那么你可以使用运算符为:
from airflow.providers.amazon.aws.operators.redshift import RedshiftSQLOperator
setup__task_create_table = RedshiftSQLOperator(
task_id='task',
redshift_conn_id="redshift_default"
sql="SELECT * FROM my_table",
)
有没有办法从气流中触发红移存储过程? 最好的情况是不使用 python 运算符,但我还没有在 airflow 版本 < 2.
中找到 reshift 运算符在 Airflow <2.1
中没有 RedShiftSqlOperator
因为 RedShift 与 PostgreSQL 兼容所以你可以只使用 PostgresOperator
:
from airflow.providers.postgres.operators.postgres import PostgresOperator
PostgresOperator(
sql='SELECT * FROM my_table',
postgres_conn_id='redshift_default',
task_id='task',
)
也就是说,在较新的版本 (Airflow >= 2.1
) 中,一些用户也在为这个问题苦苦挣扎(参见 GitHub issue) Airflow added RedshiftSQLOperator
which is available in Amazon provider 2.4.0 版:
pip install apache-airflow-providers-amazon>=2.4.0
那么你可以使用运算符为:
from airflow.providers.amazon.aws.operators.redshift import RedshiftSQLOperator
setup__task_create_table = RedshiftSQLOperator(
task_id='task',
redshift_conn_id="redshift_default"
sql="SELECT * FROM my_table",
)