Apache airflow macro to get last dag run execution time

前端 未结 2 427
鱼传尺愫
鱼传尺愫 2020-12-11 04:29

I thought the macro prev_execution_date listed here would get me the execution date of the last DAG run, but looking at the source code it seems to only get the

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 05:05

    You can make your own user custom macro function, use airflow model to search meta-database.

    def get_last_dag_run(dag_id):
      //TODO search DB
      return xxx
    
    dag = DAG(
        'example',
        schedule_interval='0 1 * * *',
        user_defined_macros={
            'last_dag_run_execution_date': get_last_dag_run,
        }
    )
    

    Then use the KEY in your template.

提交回复
热议问题