Lee-W commented on code in PR #69849:
URL: https://github.com/apache/airflow/pull/69849#discussion_r4677519626


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -163,6 +166,23 @@
 MAX_PARTITION_DAG_RUNS_PER_LOOP = 500
 
 
+def _associate_asset_events_with_dag_run(
+    *,
+    dag_run: DagRun,
+    asset_event_ids_select: Select[tuple[int]],
+    session: Session,
+) -> None:
+    """Associate selected asset events without materializing ORM objects."""
+    selected_event_ids = asset_event_ids_select.subquery()
+    session.execute(
+        insert(association_table).from_select(
+            ["dag_run_id", "event_id"],
+            select(literal(dag_run.id), selected_event_ids.c.event_id),
+        )
+    )
+    session.expire(dag_run, ["consumed_asset_events"])

Review Comment:
   Added a comment: the Core insert bypasses the ORM collection, which 
`create_dagrun` left as a loaded empty list.



-- 
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]

Reply via email to