-1

I am not sure about how to call stored procedure in airflow operator- eg. Stored Procedure is- Call goal.dba.sp_ctrl_calendar()

My code-

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)

Is this approach correct?

JaySean
  • 125
  • 1
  • 15

2 Answers2

0

in postgresql ( or redshift) to call a proc , command is call procname so your sql command shoulld look like this:

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)
eshirvana
  • 23,227
  • 3
  • 22
  • 38
0

The correct answer is-

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)
JaySean
  • 125
  • 1
  • 15