-1

我不确定如何在气流运算符中调用存储过程 - 例如。存储过程是-调用goal.dba.sp_ctrl_calendar()

我的代码-

from airflow.operators.postgres_operator import PostgresOperator
sp_ctrl_calendar = PostgresOperator(
        task_id = 'sp_ctrl_calendar',
        sql = 'goal.dba.sp_ctrl_calendar(); end;',
        postgres_conn_id = 'redshift',
        autocommit = True)

这种方法正确吗?

4

2 回答 2

0

正确答案是——

sql_command_1 = 'call goal.dba.sp_ctrl_calendar()'
sp_ctrl_calendar = PostgresOperator(
    task_id = 'sp_ctrl_calendar',
    sql = sql_command_1,
    postgres_conn_id = 'redshift',
    autocommit = True)
于 2022-01-12T06:20:19.170 回答
0

在 postgresql (或 redshift )中调用 proc ,命令是call procname 这样你的 sql 命令应该是这样的:

from airflow.operators.postgres_operator import PostgresOperator
sp_ctrl_calendar = PostgresOperator(
        task_id = 'sp_ctrl_calendar',
        sql = 'call goal.dba.sp_ctrl_calendar',
        postgres_conn_id = 'redshift',
        autocommit = True)
于 2022-01-06T17:10:15.757 回答