execution_date in airflow: need to access as a variable

后端 未结 6 893
无人共我
无人共我 2020-12-04 14:19

I am really a newbie in this forum. But I have been playing with airflow, for sometime, for our company. Sorry if this question sounds really dumb.

I am writing a p

6条回答
  •  死守一世寂寞
    2020-12-04 14:46

    To print execution date inside the callable function of your PythonOperator you can use the following in your Airflow Script and also can add start_time and end_time as follows:

    def python_func(**kwargs):
        ts = kwargs["execution_date"]
        end_time = str(ts)
        start_time = str(ts.add(minutes=-30))
    

    I have converted the datetime value to string as I need to pass it in a SQL Query. We can use it otherwise also.

提交回复
热议问题