Hi,
I am trying to pass the params in postgres operator, not hardcoding. This is coming from my previous task as you see in below:
I will be really appreciated if you are telling me what’s wrong in here and how to fix it?
get_query_id_task = PythonOperator(
task_id='get_query_id',
python_callable=query_and_push,
#provide_context=True,
op_kwargs={
'sql' : read_sql('warmupqueryid.sql')
}
)
get_query_text_task= PostgresOperator(
task_id='get_query_text',
trigger_rule=TriggerRule.ALL_DONE,
sql='rs_warm-up_query-text.sql',
parameters={'query_ids': "{{ ti.xcom_pull(task_ids='get_query_id_task', key='return_value') }}"},
)
My sql is:
SELECT LISTAGG(CASE WHEN LEN (RTRIM(TEXT)) = 0 THEN TEXT ELSE RTRIM(TEXT) END,'') within group(ORDER BY SEQUENCE) AS TEXT
FROM stl_querytext
WHERE query in ({{ macros.render_list_sql(parameters.query_ids) }});
and here is my function:
def render_list_sql(list):
return ', '.join(list)