Skip to content

Timetable that runs on multiple cron expressions - #46451

Merged
uranusjr merged 3 commits into
apache:mainfrom
astronomer:multiple-cron
Feb 6, 2025
Merged

uranusjr merged 3 commits into
apache:mainfrom
astronomer:multiple-cron

Conversation

@uranusjr

@uranusjr uranusjr commented Feb 5, 2025

Copy link
Copy Markdown
Member

This adds a new MultipleCronTriggerTimetable that takes multiple cron expressions, and schedule runs whenever the time matches at least one of the expressions. Internally, this just uses CronTriggerTimetable and check which instance gives the closest “next” run.

I specifically choose CronTriggerTimetable, not the more traditional CronDataIntervalTimetable, since the latter needs to have data interval logic, and it is very unclear how data interval should be calculated when more than one cron expression is involved.

@uranusjr uranusjr added type:new-feature Changelog: New Features type:improvement Changelog: Improvements and removed type:improvement Changelog: Improvements labels Feb 5, 2025

@eladkal eladkal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
I think we better have docs on this capability we can have example for the common use case of bi-weekly job which can't be done with single cron #8649

@eladkal eladkal added this to the Airflow 3.0.0 milestone Feb 5, 2025
@uranusjr

uranusjr commented Feb 5, 2025

Copy link
Copy Markdown
Member Author

I don’t even think multiple cron expressions can express a bi-weekly schedule though? To be able to identify bi-weekly, you’ll need some way to count weeks, which cron simply does not allow you to.

The linked issue does provide a useful example though:

every 10 min between 16:30 to 18:10

I’ll create some documentation using that instead.

@uranusjr
uranusjr requested a review from potiuk as a code owner February 5, 2025 09:21
@uranusjr
uranusjr merged commit b5a670b into apache:main Feb 6, 2025
@uranusjr
uranusjr deleted the multiple-cron branch February 6, 2025 05:33
insomnes pushed a commit to insomnes/airflow that referenced this pull request Feb 6, 2025
* Extract cron trigger timetable serde logic

* Timetable that runs on multiple cron expressions

* Add documentation for MultipleCronTriggerTimetable
niklasr22 pushed a commit to niklasr22/airflow that referenced this pull request Feb 8, 2025
* Extract cron trigger timetable serde logic

* Timetable that runs on multiple cron expressions

* Add documentation for MultipleCronTriggerTimetable
ambika-garg pushed a commit to ambika-garg/airflow that referenced this pull request Feb 17, 2025
* Extract cron trigger timetable serde logic

* Timetable that runs on multiple cron expressions

* Add documentation for MultipleCronTriggerTimetable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants