This is an automated email from the ASF dual-hosted git repository.
henry3260 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a8a2904be59 Refactor latest DagRun load options for consistency
(#67911)
a8a2904be59 is described below
commit a8a2904be594a6f8a77fee909944692120f30d79
Author: Henry Chen <[email protected]>
AuthorDate: Mon Aug 17 17:33:10 2026 +0800
Refactor latest DagRun load options for consistency (#67911)
---
.../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 8fa5209ff15..8361cc43b0c 100644
--- a/airflow-core/src/airflow/dag_processing/collection.py
+++ b/airflow-core/src/airflow/dag_processing/collection.py
@@ -103,6 +103,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 = (
@@ -124,17 +136,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())
)
@@ -160,21 +162,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):