在气流宏中传递变量
Passing variable in airflow macros
请帮助我
{{ execution_date.subtract(hours = 5) }}
这里我不想硬编码 5,而是想将其作为变量传递。
我找不到传递变量并最终使用变量值的方法。
您可以使用:
f'echo {{{{ execution_date.subtract(hours = {value}) }}}}'
BashOperator 示例:
value = 5 # This can be set dynamically
hello_my_task = BashOperator(
task_id='my_task',
bash_command=f'echo {{{{ execution_date.subtract(hours = {value}) }}}}',
dag=dag,
)
请帮助我
{{ execution_date.subtract(hours = 5) }}
这里我不想硬编码 5,而是想将其作为变量传递。
我找不到传递变量并最终使用变量值的方法。
您可以使用:
f'echo {{{{ execution_date.subtract(hours = {value}) }}}}'
BashOperator 示例:
value = 5 # This can be set dynamically
hello_my_task = BashOperator(
task_id='my_task',
bash_command=f'echo {{{{ execution_date.subtract(hours = {value}) }}}}',
dag=dag,
)