I have a sql file, having a sql query :-
delete from xyz where id in = 3 and time = '{{ execution_date.subtract(hours=2).strftime("%Y-%m-%d %H:%M:%S") }}';
Here I am writing macro in sql query itself, I want to pass it's value from python file where the operator is calling this sql query.
time = f'\'{{{{ execution_date.subtract(hours= {value1}).strftime("%Y-%m-%d %H:%M:%S") }}}}\''
I want to pass this global time variable to sql file instead of writing the complete macro there again.
PostgresOperator(dag=dag,
task_id='delete_entries',
postgres_conn_id='database_connection',
sql='sql/delete_entry.sql')
if I use time in query using jinja template as {{ time }}, instead of evaluating it, it is passed as a complete string only.
Please help, stuck on this for long.


timein two operators thus you want to avoid defining it twice?