Abhi2939 commented on issue #76549: URL: https://github.com/apache/airflow/issues/76549#issuecomment-6711663399
Hi! I'm working on a fix and will open a PR soon. I reproduced this on `main` with a regression test: a daily cron Dag (`0 0 * * *`) with a single run on Nov 5, then an hourly calendar request for December. It returns no planned runs, although the same Dag shows planned runs in Daily mode. **Root cause** `CalendarService.get_calendar_data` fetches historical runs through `_get_historical_dag_runs`, which applies the requested date filter. That result (`raw_dag_states`) is then the only baseline for `_get_planned_dag_runs`, and `_should_calculate_planned_runs` returns `False` when it is empty. - Daily uses a whole-year range, so it almost always contains a run and planned runs get calculated. - Hourly uses a one-month range, so a month with no past runs gives an empty list and no planned runs at all. **Planned fix** When the requested range has no historical runs, fall back to the Dag's latest run overall (ordered by `coalesce(partition_date, logical_date)` desc) as the baseline. The existing cron and timetable calculation then runs unchanged, because it already skips dates outside the requested range. The extra query only runs when the range is empty, so normal requests keep their current query count. I'm adding regression tests: one for a month with no history (31 planned entries for December), and one checking that nothing is planned after the Dag's `end_date`. **One side effect worth noting** An existing hourly test (the exclusive `logical_date_gt`/`logical_date_lt` case on Jan 2) currently expects an empty result because the range excludes the Jan 2 00:00 run. That is the same bug in a different form, so its expected result will change to the Jan 2 01:00 planned run. I'll call this out in the PR. **Questions** 1. Planned runs are only calculated up to the end of the same year as the last run (`year = last_data_interval.end.year`), so viewing January of the following year still shows nothing. Should that be in scope here, or left for a separate issue? 2. @its-amann, have you already started on this? If you have a branch, I'm happy to review it rather than open a duplicate PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
