I want to call the dag runtime from Airflow, however, something in my syntax is off and I need help to correct it.
I've tried this code snippet
SQL_INSERT_AIRFLOW_TS = f"INSERT INTO TRASH.TRASH.TEST_UPDATES SELECT NULL, '{{ data_interval_start }}';"
and then called it in the DAG. But it just inserts text: '{{ data_interval_start }}', instead of the date/ts
There is no reason for f-string as you are not adding parameter that you defined. data_interval_start
is Airflow macro.
Simply do:
execute_query = SQLExecuteQueryOperator(
task_id="execute_query",
sql="INSERT INTO TRASH.TRASH.TEST_UPDATES SELECT NULL, '{{ data_interval_start }}';"
)
If your real use case is to use both user defined parameters and macros see this answer.