Skip to content

Fix Dag list filtering to include QUEUED DagRuns with null start_date #52668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions airflow-core/src/airflow/api_fastapi/common/db/dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

from typing import TYPE_CHECKING

from sqlalchemy import func, null, select
from sqlalchemy import func, null, or_, select

from airflow.api_fastapi.common.db.common import (
apply_filters_to_select,
)
from airflow.api_fastapi.common.parameters import BaseParam, RangeFilter, SortParam
from airflow.models import DagModel
from airflow.models.dagrun import DagRun
from airflow.utils.state import DagRunState

if TYPE_CHECKING:
from sqlalchemy.sql import Select
Expand All @@ -37,7 +38,7 @@ def generate_dag_with_latest_run_query(max_run_filters: list[BaseParam], order_b

max_run_id_query = ( # ordering by id will not always be "latest run", but it's a simplifying assumption
select(DagRun.dag_id, func.max(DagRun.id).label("max_dag_run_id"))
.where(DagRun.start_date.is_not(null()))
.where(or_(DagRun.start_date.is_not(null()), DagRun.state == DagRunState.QUEUED))
.group_by(DagRun.dag_id)
.subquery(name="mrq")
)
Expand Down