This is an automated email from the ASF dual-hosted git repository.
henry3260 pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 490f5e28694 [v3-3-test] Refactor latest DagRun load options for
consistency (#67911) (#71706)
490f5e28694 is described below
commit 490f5e2869428b27eaf67c8da61b039e44e024b8
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Aug 17 19:17:42 2026 +0800
[v3-3-test] Refactor latest DagRun load options for consistency (#67911)
(#71706)
(cherry picked from commit a8a2904be594a6f8a77fee909944692120f30d79)
Co-authored-by: Henry Chen <[email protected]>
---
.../src/airflow/dag_processing/collection.py | 40 ++++++++--------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/airflow-core/src/airflow/dag_processing/collection.py
b/airflow-core/src/airflow/dag_processing/collection.py
index 9ea66e60ed3..17d23394cb9 100644
--- a/airflow-core/src/airflow/dag_processing/collection.py
+++ b/airflow-core/src/airflow/dag_processing/collection.py
@@ -104,6 +104,18 @@ def _create_orm_dags(
yield orm_dag
+def _build_latest_run_load_options() -> Any:
+ return load_only(
+ DagRun.dag_id,
+ DagRun.logical_date,
+ DagRun.run_after,
+ DagRun.data_interval_start,
+ DagRun.data_interval_end,
+ DagRun.partition_key,
+ DagRun.partition_date,
+ )
+
+
def _get_latest_runs_stmt(dag_id: str) -> Select:
"""Build a select statement to retrieve the last automated run for each
dag."""
max_logical_date = (
@@ -125,17 +137,7 @@ def _get_latest_runs_stmt(dag_id: str) -> Select:
DagRun.dag_id == dag_id,
DagRun.logical_date == max_logical_date,
)
- .options(
- load_only(
- DagRun.dag_id,
- DagRun.logical_date,
- DagRun.run_after,
- DagRun.data_interval_start,
- DagRun.data_interval_end,
- DagRun.partition_key,
- DagRun.partition_date,
- )
- )
+ .options(_build_latest_run_load_options())
)
@@ -161,21 +163,7 @@ def _get_latest_runs_stmt_partitioned(dag_id: str) ->
Select:
.limit(1)
.scalar_subquery()
)
- return (
- select(DagRun)
- .where(DagRun.id == latest_run_id)
- .options(
- load_only(
- DagRun.dag_id,
- DagRun.logical_date,
- DagRun.run_after,
- DagRun.data_interval_start,
- DagRun.data_interval_end,
- DagRun.partition_key,
- DagRun.partition_date,
- )
- )
- )
+ return select(DagRun).where(DagRun.id ==
latest_run_id).options(_build_latest_run_load_options())
class _RunInfo(NamedTuple):