ashb commented on code in PR #63568:
URL: https://github.com/apache/airflow/pull/63568#discussion_r2974587013
##########
airflow-core/src/airflow/models/taskmap.py:
##########
@@ -254,6 +268,18 @@ def expand_mapped_task(
task.log.debug("Expanding TIs upserted %s", ti)
task_instance_mutation_hook(ti)
ti = session.merge(ti)
+ if unmapped_ti:
+ dr = unmapped_ti.dag_run
+ else:
+ from airflow.models import DagRun
+
+ dr = session.scalar(
+ select(DagRun).where(
+ DagRun.dag_id == task.dag_id,
+ DagRun.run_id == run_id,
+ )
+ )
Review Comment:
Using `where` here will cause SQLA to issue a query for _each and every_
time around this loop, even if we are mapping the same Task 1000 times. We'll
need to do something better here
--
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]