How to define a DAG that scheduler a monthly job together with a daily job?

好久不见. 提交于 2019-12-17 17:15:59

问题


I have to

  • update a table Foo monthly
  • and another table Bar daily
  • and join these two tables daily and insert the result into a third table Bazz

Is it possible to configure that

  • Foo is updated on certain day (say 5th),
  • while Bar is updated daily
  • and they are in the same DAG?

回答1:


This behaviour can be achieved within single DAG using either of following alternatives

  • ShortCircuitOperator
  • AirflowSkipException (better in my opinion)

Basically, your DAG would still run each day (schedule_interval='@daily'), but

  • on a daily basis, only your Bar task would run while Foo would get skipped (or short-circuited);
  • until on some particular day (like 5th of each month) when both would run.

You can, of course, also model these as separate DAGs and chain them together (rather than individual tasks within a single DAG). This choice might be better till the number of DAGs that you are linking together is small.



来源:https://stackoverflow.com/questions/57104547/how-to-define-a-dag-that-scheduler-a-monthly-job-together-with-a-daily-job

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!